Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling thread must be STA
Message
From
16/07/2010 10:54:02
 
 
To
16/07/2010 08:53:07
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01472690
Message ID:
01472706
Views:
53
>I just downloaded the trial for MM and ran through the Business Objects Framework then the jump start for a WPF app.
>
>When I run the WPF app I get the error:
>"The calling thread must be STA, becuase many UI components require this"
>
>This occurs very early in the app startup on the constructor statement 'public MainWindow()':
>
>
>    public partial class MainWindow; mmMainAppWindow
>        public MainWindow();
>        {
>            InitializeComponent();
>        }
>
>
>I see plenty of Google responses to this issue with respect to Nunit testing. But I never had the issue when I ran NUnit against the Business Object DLL. This only happens running the WPF app project.
>
>How do I fix this, as it is all just generated code? I assume perhaps I misnamed one of the objects in the jump start?


Do you have a Main() that is not generated ? If so put [STAThread] before it like in the example below
namespace BaseTest
{
	class Program
	{
		[STAThread]
		static void Main()
		{
			Window win = new Window();
			win.Title = "The Title";
			win.Content = "Hello World";
			Application app = new Application();
			app.Run(win);
		}
	}


}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform