Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 890
Louis Rhys Avatar asked Jan 28 '11 06:01

Louis Rhys


1 Answers

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:

  • https://connect.microsoft.com/VisualStudio/feedback/details/526836/wpf-appdomain-assemblyresolve-being-called-when-it-shouldnt
  • http://blogs.msdn.com/b/kimhamil/archive/2008/11/11/what-does-the-neutralresourceslanguageattribute-do.aspx
  • http://forums.devshed.com/net-development-87/c-wpf-appdomain-assemblyresolve-being-called-when-it-shouldn-t-669567.html
like image 98
HuseyinUslu Avatar answered Sep 26 '22 11:09

HuseyinUslu