acezrwild817 0 Light Poster

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.