-
March 28th, 2014, 01:23 PM
#1
STA error Exception.InnerException
Hi,
I need a little help on an InvalidoperationException was unhandled by user code.
The error occurs when I call this Sub located in a Module from a Timer (System.Timers.Timer) also located in the Module.
Thank you in advance.
This is a Google translation of the error message from VB.NET
An error occurred during the creation of the form. See Exception.InnerException for more information. The error was: User thread should be STA, because this is required for many UI components.
Code:
Public Sub SetSpeechActive(ByVal TurnOn As Boolean)
If TurnOn Then
frmMain.picSpeechActive.Image = System.Drawing.Image.FromFile(System.Windows.Forms.Application.StartupPath & "\images\online16.png")
Else
frmMain.picSpeechActive.Image = System.Drawing.Image.FromFile(System.Windows.Forms.Application.StartupPath & "\images\offline16.png")
End If
End Sub
-
March 28th, 2014, 03:27 PM
#2
Re: STA error Exception.InnerException
The error message would seem to indicate that you have launched a new thread where this code is running but you are trying to update the GUI and the thread doesn't support it
Always use [code][/code] tags when posting code.
-
March 28th, 2014, 04:05 PM
#3
Re: STA error Exception.InnerException
Originally Posted by DataMiser
The error message would seem to indicate that you have launched a new thread where this code is running but you are trying to update the GUI and the thread doesn't support it
Yes you are right. How would I update the picturebox from this thread. I don't know much about threads.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|