January 21st, 2010, 04:57 PM
[Solved] C# WPF AppDomain Error
I'm trying to get an Application class I have developed for .NET 3.5 to work with .NET 4.0 Beta 2. I have created a new default WPF project in both Visual Studio 2008 and 2010 beta 2, and have the following is the base class definition for both App.xaml.cs files.
public partial class App : Application
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
The problem is that the CurrentDomain_AssemblyResolve method is being called in .NET 4.0, but isn't in .NET 3.5. The resource being requested is called "resources". But as far to my knowledge, the method should never be called, as it should have already been resolved. If you remove the code then it works as normal, and the "resources" resource is loaded as it should be.
I have also noticed several other bugs with code similar to this in some of my other .NET 3.5 applications. Most notably with console applications. The issue does not seem to be documented anywhere, so I was wondering whether anybody knows why this is happening.
Last edited by shivercube; January 26th, 2010 at 06:02 PM.
Reason: Changed title
January 24th, 2010, 06:03 AM
Does nobody know the answer to this?
It seems that if you remove resources all together, then the error dissapears. But this still doesn't make sense because if you remove the handler, the resources will get resolved normally. I think this may have something to do with the assembly information language settings of the project, but still, this does not make any sense!
January 26th, 2010, 06:08 PM
I have finally managed to find a solution from Microsoft Connect.
I still do not understand what the problem is, but adding the following line to AssemblyInfo.cs solves it.
Originally Posted by CommonGenius.com
[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.MainAssembly)]