Friday, September 19, 2008

System.Resources.MissingManifestResourceException was unhandled by user code

My localization of a web app throws exception:"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyResource.resources" was correctly embedded or linked into assembly "WebApplication1" at compile time, or that all the satellite assemblies required are loadable and fully signed.".

You cannot use VS 2005 way in VS2008.

In VS2005, you can use:
Assembly asm = Assembly.Load(assemblyName);
ResourceManager rm = new ResourceManager(baseName, asm);

In VS2008, you have to include the web application name in basename:
ResourceManager rm = new ResourceManager(".", Assembly.GetExecutingAssembly(), null);

Furthermore, I found I cannot put the resource files in App_GlobalResources directory. It may be possible but it is not straightforward at least. I have to create a new resource file under the project root directory.

No comments: