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).