Skip to content

System.InvalidOperationException

Roy

Asked Jul 16, 2006, 6:06 PM EDT1 answer
Share
LinkedInX

I am having a problem with a System.InvalidOperation exception.  There is a combo box in my code and when the index is changed i have a a treeview item that is cleared and then rebuilt.  However, when I go to add the first node I receive the following exception:

 

System.InvalidOperationException: Action being performed on this control is being called from the wrong thread.  Marshall to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action.

I only have one thread in my code and it is the Main form default thread.  Furthermore, the exception does not always occur.  It occurs randomly.  The specific line to which to error is returned is the line at which I am adding my first node to my tree.  I have no idea why this exception is being thrown.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Might be you have some hidden thread spawned by one of the form controls.

    Try using Control.Invoke when populating the treeview control
    0