MissingManifestResourceException may not mean what you think it means

1 12 2010

After a very minor change I made in a .NET form’s code I started getting a System.Resources.MissingManifestResourceException every time the form was opened. I haven’t changed anything to do with the resources or the project file so I couldn’t understand what was going on.

A cow-orker was called in to assist and he promptly tried to open the designer (this is something I never do, I’m a “view code” kind of guy) and the designer failed to open because:

Visual Studio requires that designers use the first class in the file.

Indeed my change was to add a static helper class to the namespace

namespace Foo.Bar
+    public static class SomeFeature
+    {
+        static bool enabled;
+        static SomeFeature() 
+        {
+            /* initialize enabled */
+        }
+        public static bool Enabled
+        {
+            get  {  return enabled;  }
+        }
+    }

  public partial class LameForm : Form

Moving the SomeFeature class to another file solved the issue.

I would like to take this opportunity to thank Microsoft for making this a runtime error rather than a compile time error (or warning) and for not giving a clear and relevant exception, otherwise I may have had to find something else to do all day (like some real work God forbid).




One response

28 01 2018
What does MissingManifestResourceException mean and how to fix it? - QuestionFocus

[…] For (slightly) more information see this post. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: