Search code examples
.netwpfresourcesassembliesassembly-resolution

AssemblyResolve always get raised, asking for MyAssembly.resources


I have a WPF application, and I subscribe to the event AppDomain.AssemblyResolve (this event get raised whenever the runtime does not find an assembly), and I notice it gets call several times trying to resolve MyAssembly.resources, where MyAssembly is the current executing assembly. It also asked the same thing for a library assembly I referenced from MyAssembly (it asked for Library.resources).

Is this normal? How do I fix it? My application does have a problem. It cannot load some xaml user control located in the library. Is this related?


Solution

  • Add this line to your AssemblyInfo.cs and your resolver will not get asked for resources any-more.

    [assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.MainAssembly)]
    

    Though this is a work-around should be carefully considered multi-language applications.

    More Info: