Assembly aspects have not been initialized

avistokar's Avatar

avistokar

02 Oct, 2017 12:34 PM

When I execute CachingServices.Invalidation.Invalidate(getPoliciesAsync) I get this message. At the very beginning of my WPF app (in the static ctor of App in app.xaml.cs) I call setup caching using CachingServices.DefaultBackend = new MemoryCachingBackend( new MemoryCache("myCache") );

This class is in a different assembly that the main executable with the App.xaml.cs that contains the above code. Is there a step I need to do for each assembly?

  1. Support Staff 1 Posted by PostSharp Techn... on 03 Oct, 2017 09:53 AM

    PostSharp Technologies's Avatar

    Hello,

    CachingServices.DefaultBackend is a property backed by a static field, so you have to initialize it once for the whole application (AppDomain).

    Please, could you check if CachingServices.Invalidation.Invalidate is not called from any static constructor?

    You can initialize the caching backend sooner than from WPF app static constructor by using a module initializer:

    [ModuleInitializer(1)]
    public static void Initialize()
    {
        CachingServices.DefaultBackend = new MemoryCachingBackend(new MemoryCache("myCache"));
    }
    

    Please, what is the exact error message?

    Please, do you use multiple AppDomains in your app? If yes, then you have to initialize the caching backend for each AppDomain.

    -jakub

  2. Support Staff 2 Posted by PostSharp Techn... on 06 Nov, 2017 12:47 PM

    PostSharp Technologies's Avatar

    Hello,

    We are going to close this request as there have not been any further updates. Please feel free to reopen the discussion if you need more help.

    Thanks,
    PostSharp Team

  3. PostSharp Technologies closed this discussion on 06 Nov, 2017 12:47 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac