2009-08-28 43 views
0

我创建了一个表单应用程序与1按钮和1个文本框,看看我是否可以重新创建这个错误,我做到了。在编译并试图与F5运行我不断收到此错误Windows类的名称是无效的错误 - VS 2008/C#

 at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass() 
    at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle) 
    at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) 
    at System.Windows.Forms.Control.CreateHandle() 
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 
    at System.Windows.Forms.Control.CreateControl() 
    at System.Windows.Forms.Control.WmShowWindow(Message& m) 
    at System.Windows.Forms.Control.WndProc(Message& m) 
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m) 
    at System.Windows.Forms.ContainerControl.WndProc(Message& m) 
    at System.Windows.Forms.Form.WmShowWindow(Message& m) 
    at System.Windows.Forms.Form.WndProc(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 

这是我的主:

static void Main() 
    { 
     Application.EnableVisualStyles(); 
     Application.SetCompatibleTextRenderingDefault(false); 
     **Application.Run(new Form1());** 
    } 

错误发生在BOLD

回答

0

正好遇到这同时与一个老项目在Visual Studio 2005中的工作有点搜索我的记忆后,慢跑,易记,这已经是与Visual Studio托管过程,我通过执行以下操作来修复它: - 转到生成 - >清理解决方案 - 退出Visual Studio,打开Windows资源管理器,然后转到您正在使用的配置的bin目录(即,如果您在Debug配置中,请转到\ bin \ Debug)。 - 应该只剩下几个文件,最显着的是主机进程可执行文件(.vshost.exe)。删除这一个,并保证与主机进程可执行文件关联的任何.config和.manifest文件都是安全的。 - 重新启动Visual Studio并再次构建您的解决方案。

通过在不清除解决方案的情况下删除主机进程可执行文件来解决此问题是可能的。通过转到项目属性,调试设置以及取消选中“启用Visual Studio托管过程”复选框,也可以删除可执行文件。不过,托管进程加快了加载Debug版本的速度,所以如果可以的话,重新启用它。

(编辑)重温这个之后,我发现了另一种可能的解决方案。下面一行添加到main()函数,调用Application.Run()之前:

Application.EnableVisualStyles(); 
相关问题