2012-03-29 24 views
1
OpenFileDialog^ dialog = gcnew OpenFileDialog; 
dialog->ShowDialog(); 

這可能是什麼錯誤? 我使用Visual Studio 2008專業在Windows 7上使用.NET Framework 3.5的 我創建了一個按鈕,並添加點擊功能,我把上面的代碼,而只是把這個錯誤:C++/CLI中的Super Basic OpenFileDialog出錯

An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll 

我把它翻譯從葡萄牙語到英語,因爲我的Visual Studio在葡萄牙語中拋出錯誤。

Additional information: The current thread should be defined in STA Mode (Single Thread Apartment) before OLE calls can be done. Check if the Main Function has STAThreadAttribute checked. The Exception will only be generated if the debugger is attached to the thread (or maybe process).

,這是葡萄牙語語言的原始錯誤:

Additional information: O thread atual deve ser definido no modo STA (single thread apartment) antes que chamadas OLE possam ser feitas. Verifique se a função Main tem STAThreadAttribute marcado. A exceção somente será gerada se um depurador estiver anexado ao processo.

順便說一句,所有的微軟默認的東西設置,該Windows創建項目時窗體應用程序預設的所有庫, 希望我很清楚 預先感謝

回答