I recently updated a simple program that uses a filedialog control to locate
a file. When I try and run the following code I get this error:
Current thread must be set to single thread apartment (STA) mode before OLE
calls can be made. Ensure that your Main function has STAThreadAttrib ute
marked on it. This exception is only raised if a debugger is attached to the
process.
Here is the code
this.openFileDi alog1.FileName = this.txtCompile Path.Text;
DialogResult result = openFileDialog1 .ShowDialog(thi s);
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
this.txtCompile Path.Text = openFileDialog1 .FileName;
}
a file. When I try and run the following code I get this error:
Current thread must be set to single thread apartment (STA) mode before OLE
calls can be made. Ensure that your Main function has STAThreadAttrib ute
marked on it. This exception is only raised if a debugger is attached to the
process.
Here is the code
this.openFileDi alog1.FileName = this.txtCompile Path.Text;
DialogResult result = openFileDialog1 .ShowDialog(thi s);
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
this.txtCompile Path.Text = openFileDialog1 .FileName;
}
Comment