无法为此文件显示设计器,因为无法设计其中的任何类 [英] The designer could not be shown for this file because none of the classes within it can be designed

查看:41
本文介绍了无法为此文件显示设计器,因为无法设计其中的任何类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有以下共享组件:

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

在 Windows 设计器中,类正确显示.

In the Windows Designer, the class shows properly.

当我将服务更改为从 OurServiceBase 派生时

When I change the service to derive from OurServiceBase

public class MyService : OurSharedLibrary.OurServiceBase

设计师停止工作:

完整的错误是:无法为此文件显示设计器,因为无法设计其中的任何类.设计人员检查了文件中的以下类: EmailProcessor --- 无法加载基类OurSharedLibrary.CienaServiceBase".确保已引用程序集并且已构建所有项目.

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.

欢迎提出任何建议.

更多信息 - 设计器在呈现无法设计派生服务的错误时的调用堆栈:

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 新发现.

7/19/2011 2:34PM EDT New discovery.

OurServiceBase"类存在于一个单独的项目中(通常仅作为 DLL 引用).一时兴起,我将基类文件复制到我的项目中,构建并打开了设计器.有效!当我再次删除基类文件并返回外部DLL引用时,设计器再次崩溃.

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.

推荐答案

你最好的办法是从一个没有功能的 OurServiceBase 版本开始,看看你是否可以设计 MyService.如果是这样,那么慢慢添加功能,直到它中断.

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.

因为看起来 Visual Studio 在序列化 OurServiceBase 的成员之一时遇到问题.

Since it looks like Visual Studio is having a problem serializing one of the members of OurServiceBase.

这篇关于无法为此文件显示设计器,因为无法设计其中的任何类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆