user1092719 user1092719 - 10 months ago 37
C# Question

"Base class could not be loaded" - for no clear reason

I'm using Visual C# 2008 Express. This is the first time I've had this error in years, the last time I had it was around the time I started programming.

I have no idea what it actually means or why it suddenly came up, it seems rather ambiguous for what the error message says. All I know is that throughout my app, I inherit a lot of the main windows from a ThemedWindow class I came up with to give them a custom appearance, there are no errors in that code and everything was working 100% perfect 20 minutes ago.

The error in full:

Warning 12 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

InheritingWindow --- The base class 'ThemedWindow' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. 0 0

I get that for every form that inherits from ThemedWindow, and several other errors because the project won't build far enough for everything else to work.

Just before this happened I updated the font on all forms and sub-controls, the project even built and ran after I did that, then this happened for absolutely no clear reason.

I've tried the classic rebuild it, delete build files, reopen Visual Studio etc, but nothing seems to work at the moment.

Does anyone know how to fix this?

Answer Source

These problems were caused by an unfortunate bug in Visual Studio. I had other errors (not warnings) in some code, even though nothing else directly depended upon it, which played a part in this whole situation.

I could be wrong in explaining it but here's what I think went wrong: for some reason (bug), it totally forgot about unchanged objects it had already compiled before, gave me the actual errors I had in my code, and a bunch of other warnings because it wouldn't go past that point. I couldn't get into the designer for forms that depended upon ThemedWindow because I'm guessing ThemedWindow hadn't recompiled before these errors occurred.

Once I commented out the erroneous code as a quick fix and rebuilt the solution, everything compiled successfully.