ASP.NET WCF Service error "The calling thread must be STA, because many UI components require this. "? -
I have some window workflow that use some .net assemblies. I'm reaching some hardware from these workflow windows, my XYZ services being published on IIS through the Virtual Directory methodology, all help. Now I want to consume my workflow with my net web application. I have created a WCF service and a web client (on web client request) try to load workflows (success) and execute my WCF service
The problem is that when I call the execution of the load workflow, it gives the exception "The calling thread should be STA, because many UI components need it." < /p> If you do not have a single thread apartment thread using a WinForms / WPF object from a thread This will be an exception. In order to use those items from your WCF service, you need to create a new thread, My trivial example takes a string and it checks against a spell check feature of a WPF text box: You can also refer to this SEO. Post: Also the answer in the answer: STA that is to set up the flat state on the thread and then start the thread.
public ValidatePassword (string password) bool {bool Is = false; If (string.IsNullOrEmpty (password) == incorrect) {Thread T = New thread ((=) gt; {System.Windows.Controls.TextBox tbWPFTextBox = New System.Windows.Controls.TextBox (); tbWPFTextBox.SpellCheck IsEnabled = True; tbWPFTextBox.Text = password; tbWPFTextBox.GetNextSpellingErrorCharacterIndex (0, System.Windows.Documents.LogicalDirection.Forward); difference spellingErrorIndex = tbWPFTextBox.GetNextSpellingErrorCharacterIndex (0, System.Windows.Documents.LogicalDirection.Forward); if (spellingareindexx = = -1) {isValid = true;} and {isValid = false;}}); T.SetApartmentState (ApartmentState.STA); T.Start (); T.Join (); } Return is valid; }
Comments
Post a Comment