【发布时间】:2012-03-29 02:29:39
【问题描述】:
OpenFileDialog^ dialog = gcnew OpenFileDialog;
dialog->ShowDialog();
这可能有什么问题? 我在带有 .NET Framework 3.5 的 Windows 7 上使用 Visual Studio 2008 Professional 我创建了一个按钮并添加了一个 Click Function,然后我输入了上面的代码,然后抛出了这个错误:
An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
我将它从葡萄牙语翻译成英语,因为我的 Visual Studio 用葡萄牙语抛出了错误。
附加信息:当前线程应在 STA 中定义 可以完成 OLE 调用之前的模式(单线程单元)。检查是否 Main 函数检查了 STAThreadAttribute。例外将 仅当调试器附加到线程时才会生成(或者可能 过程)。
这是葡萄牙语的原始错误:
附加信息:O thread atual deve ser definido no modo STA (单线程公寓)ante que chamadas OLE possam ser feitas。 Verifique se a função Main tem STAThreadAttribute marcado。一个例外 somente será gerada se um depurador estiver anexado ao processo。
顺便说一下,所有微软默认的东西都设置好了,Windows Forms Application在创建项目时预设的所有库, 我希望我足够清楚 提前致谢
【问题讨论】:
标签: visual-studio-2008 mfc c++-cli