Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling thread must be STA
Message
De
16/07/2010 10:54:02
 
 
À
16/07/2010 08:53:07
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01472690
Message ID:
01472706
Vues:
54
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform