Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 打开FolderBrowser时显示异常_C# 4.0 - Fatal编程技术网

C# 4.0 打开FolderBrowser时显示异常

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

我想选择路径,所以我使用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 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();
    }