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

11,232

Solution 1

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.

Solution 2

Build your base usercontrol class with AnyCPU option.

Share:
11,232
user1092719
Author by

user1092719

Updated on June 05, 2022

Comments

  • user1092719
    user1092719 about 2 years

    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?

  • Alin Ciocan
    Alin Ciocan over 8 years
    For me it worked to close Visual Studio, open it again in Administrator mode and rebuild again the solution and it worked.
  • Obi Wan
    Obi Wan about 7 years
    You say these problems were caused by..., speaking in the past tense as if this is no longer problem. This is a problem right now in the latest version of VS.
  • Eric Eskildsen
    Eric Eskildsen over 2 years
    @AlinCiocan Restarting Visual Studio resolved it for me. Thanks.