От: | Dmitriy Dubrovskiy | ||
Дата: | 08.08.06 13:35 | ||
Оценка: |
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.
at System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at System.Windows.Forms.CommonDialog.ShowDialog()
at DataOrganizer.Forms.MainForm..ctor() in D:\Dubrovskij\My documents\Visual Studio 2005\Projects\DataOrganizer\DataOrganizer\MainForm.cs:line 26
at DataOrganizer.Forms.Program.Main() in D:\Dubrovskij\My documents\Visual Studio 2005\Projects\DataOrganizer\DataOrganizer\Program.cs:line 24
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
_saveFileDialog.ShowDialog();
}
....
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
}