2009-08-28 51 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(); 
相關問題