Understanding why you get a MissingManifestResourceException

Ever wonder why you get a mysterious MissingManifestResourceException? The fallowing message board post describes this problem.

Felix Wu(MS) [@online.microsoft.com]

Hi Srini,

Are you talking the MissingManifestResourceException? This problem can occur when the resource can not be successfully loaded.

Do you have any custom classes defined before the default Form1 class? Since the compiler use the name of the first class as the default resource name for the form.

For example, you can find similar lines in the assembly's manifest (Note: You can check the compiled assemblies using ildasm.exe utility):

.mresource public WindowsApplication1.Form1.resources

As you can see, "Form1" is from the name of the first class in the code module. If you put another class, "MyClass" for example, before the "Form1" class, the resource
name will be changed to "WindowsApplication1.MyClass.resources". This makes the call:

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

fail to locate the resource.

If this is not the case, please explain a little bit more about problem, and I'm glad to look into it.


Felix Wu
This posting is provided "AS IS" with no warranties, and confers no rights.

So if you  are getting the missing MissingManifestResourceException be sure to check if you have declared any classes before the Form class. I am unsure weather or not this was fixed after visual studio 2002. I am posting this here because I ran into the same problem and could not for the life of me figure out why I was getting this exception. Finnaly I tracked down the problem.

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume