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 STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process. Here is the code this.openFileDialog1.FileName = this.txtCompilePath.Text; DialogResult result = openFileDialog1.ShowDialog(this); if (openFileDialog1.ShowDialog() == DialogResult.OK) { this.txtCompilePath.Text = openFileDialog1.FileName; }
↧
Current thread must be set to single thread apartment (STA) mode before OLE
↧