We have the following shared component:
public class OurServiceBase : System.ServiceProcess.ServiceBase
This class has functionality we want in all our downstream services, such as standardized execution scheduling and logging functionality.
In a new project, I add the following:
public class MyService : System.ServiceProcess.ServiceBase
In the Windows Designer, the class shows properly.
When I change the service to derive from OurServiceBase
public class MyService : OurSharedLibrary.OurServiceBase
The designer stops working:

The full error is: 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: EmailProcessor --- The base class 'OurSharedLibrary.CienaServiceBase' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
The proper assemblies are referenced, the project builds. I don't understand why the designer is flipping out over this since my service ultimately does derive from a designable class.
Any suggestions would be most welcome.
Bit more information - the call stack from the designer when it renders the error about not being able to design the derived service:
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
7/19/2011 2:34PM EDT New discovery.
Class "OurServiceBase" exists in a separate project (usually referenced as a DLL only). On a whim, I copied the base class file into my project, built, and opened the designer. It worked! When I removed the base class file again and returned to the external DLL reference, the designer broke again.
Your best bet would be to start with a version of OurServiceBase
with no functionality and see if you can design MyService
. If so, then slowly add back functionality until it breaks.
Since it looks like Visual Studio is having a problem serializing one of the members of OurServiceBase
.
You can also try doing this:
- Close all the UI design pages
- Clean Solution
- Build Solution
- Open the desired UI design pages
This might or might not help but it certainly resolved the same issue in my project.
Just in case some one like me have to work on a old project base on Visual Studio 2008 and face the same problem.
It's probably because the project path contain some exotic chars like C#
Example, my path look like that :
C:\projects\C#\projectname...
When it's renamed to
C:\projects\CSharp\projectname...
Visual Studio is now able to recognize parent class and then open the form with the inherited form.
Here's another possible solution:
Under the project properties under build, my platform target was set to x64. I updated this to "Any CPU", rebuilt my project and the designers opened fine.
This explains it better: Visual studio designer in x64 doesn't work
You may also run into this problem if your control/service is inheriting from a generic class. The designer doesn't get along well with abstract classes in the hierarchy, since it has to instantiate them.
I had a solution with 2 projects (one referencing the other) and I had just set one to target .Net 4.5.2 and the other was targetting 4.5.
Tip: view the warning messages in the Error List:
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:....dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
来源:https://stackoverflow.com/questions/6683255/the-designer-could-not-be-shown-for-this-file-because-none-of-the-classes-within