hi guys,
I'm writting a simple text editor using visual studio 2008. When I'm trying to
make a new instance of the application using the following code which is existed
in Main() method
[STAThread]
private static void newInstance() {
//the following code also exists in Main() method
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
the application creates a new instance, but the problem is when try to open,
save, and any other action the application generate a "ThreadStateException"
which says
"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."
How to solve this bug, or where I can find an answer???
Thanks in advance.