C# 4.0 打开FolderBrowser时显示异常
我想选择路径,所以我使用Folderbrowser对话框。但是在“DialogResult=fbd.ShowDialog();”行显示异常是错误的C# 4.0 打开FolderBrowser时显示异常,c#-4.0,C# 4.0,我想选择路径,所以我使用Folderbrowser对话框。但是在“DialogResult=fbd.ShowDialog();”行显示异常是错误的 Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This ex
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
public void OpenFolder()
{
}在main方法上方添加[STAThreadAttribute]属性
[STAThreadAttribute]
static void Main(string[] args)
{
OpenFolder();
}
异常消息特别告诉您查看Main()方法。看来你没看,我们看不见。
[STAThreadAttribute]
static void Main(string[] args)
{
OpenFolder();
}