ورود

View Full Version : خطا The calling thread must be STA در هنگام ساخت شی mainWindow



amin_sltny
دوشنبه 21 مهر 1393, 11:21 صبح
سلام بچه هامن کد زیر را توی app برنامه نوشتم


private void Application_Startup(object sender, StartupEventArgs e)
{
System.Windows.Forms.Application.EnableVisualStyle s();
System.Windows.Forms.Application.SetCompatibleText RenderingDefault(false);
if (MyServer.IsAdministrator())
{
if (MyServer.IsRun())
Process.GetCurrentProcess().Kill();
else
{
MainWindow ObjMain = new MainWindow();
ObjMain.Show();
}
}
else
{
new CheckRunAsAdministrator().ShowDialog();
Process.GetCurrentProcess().Kill();
}

}

اما نمی دونم چی شد بعد از یکم تغییرات توی برنامه ام با خطای زیر مواجه می شم

124499

amin_sltny
دوشنبه 21 مهر 1393, 16:56 عصر
بچه ها من امدم و Application_Startup را از بین بردم و به جاش در app.xaml نوشتم StartupUri="MainWindow.xaml" و این بار با خطای زیر مواجه شدم




A first chance exception of type 'System.NotImplementedException' occurred in PresentationFramework.dll


Additional information: The method or operation is not implemented.

parvizwpf
دوشنبه 21 مهر 1393, 17:33 عصر
http://stackoverflow.com/questions/2329978/the-calling-thread-must-be-sta-because-many-ui-components-require-this