Reputation: 147
The error Im getting : The calling thread must be STA, because many UI components require this.
So I have an android application which generates a bill of materials on the server side. Therefore a new UI has to be generated for the bill of materials. When I try to add a product to the BOM..this is the error I am getting. How do I go about it. An solution allowing me to host the service the android application is using is already running. The BOM application is a part of this solution.
Upvotes: 0
Views: 911
Reputation: 724
When you create a new thread in your application, set its apartement state like in the code below before you start it:
Thread myThread = new Thread(() =>
{
});
myThread.SetApartmentState(ApartmentState.STA);
myThread.Start();
If you do not create new Threads like this you may have to declare you "main" or "startup" -method with an [STAThread] - attribute. See here: Why does WPF require a STAThread attribute to be applied to the Main method?
Upvotes: 1