Click to See Complete Forum and Search --> : FileDialog


shr6557
December 22nd, 2006, 01:28 PM
hello
i want get file with OpenFileDialog class
i use this code

OpenFileDialog ^chooser = gcnew OpenFileDialog;
chooser->ShowDialog;

i dubug my program , this is not have error but when my program must show FileDialog compiler break my program and show this error


A first chance exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll
An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll

Additional information: 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.


plz help me!
tnx

TheCPUWizard
December 22nd, 2006, 01:37 PM
Please pase your code for main() along with any attributes that proceed it.

[Remember to use code tags, if you don't know how, please read the FAQ.]