STAThread missing, but it is there

前端 未结 5 964
遥遥无期
遥遥无期 2020-12-01 22:24

Here is the error message that I am recieving when I try to open an OpenFileDialog in my program:

\"Current thread must be set to single thread apar

5条回答
  •  隐瞒了意图╮
    2020-12-01 23:05

    Can't say without code. If a console app, add the following before you call the method:

    Console.Write(System.Threading.Thread.CurrentThread.ApartmentState);
    

    otherwise,

    MessageBox.Show(System.Threading.Thread.CurrentThread.ApartmentState);
    

    and see what the threading apartment state REALLY is.

提交回复
热议问题