System.Threading.ThreadStateException
martinsalo
Hello Forum,
I want to add a form with a webbrowser control to SAP. I'm trying this code:
private void OpenIEFormClicked(SwissAddonFramework.UI.EventHandling.MenuEvents.MenuClick ev) {
try {
WebControlIE myForm = new WebControlIE();
System.Windows.Forms.WebBrowser IE = new System.Windows.Forms.WebBrowser();
myForm.Controls.Add(IE);
myForm.LoadToSap();
} catch (Exception ex) {
throw;
}
}
While creating the WebBrowser Control I get this exception:
"System.Threading.ThreadStateException: Das ActiveX-Steuerelement 8856f961-340a-11d0-a96b-00c04fd705a2 kann nicht instanziiert werden, da der aktuelle Thread kein Singlethread-Apartment ist.
bei System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
bei System.Windows.Forms.WebBrowser..ctor()
"
Translated:
The ActiveX Control could not be instantiated, because the current thread is not a singlethreaded apartment.
The Starter Project has the [STAThread] attribute in the main routine. What else could be the problem?
Thanks
Martin
martinsalo
I have created an addon with one menu and on a click, this lines are executed:
System.Threading.ApartmentState ThreadState = System.Threading.Thread.CurrentThread.GetApartmentState();
SwissAddonFramework.Messaging.StatusBar.WriteError("ApartmentState: " + ThreadState);
I have compiled the addon and installed the Sip file. Its a MTA environment?!
0
Please sign in to leave a comment.
Comments
0 comments