In my app, I have a toolbarcontrol, the table of contents control, and the map control.
For some reason the toolbar control will not allow itself to be disposed of. I can set the reference to Nothing, but I cannot call dispose on it, and any attempt to do so throws the "InvalidOperationException" with the message...
Cross-thread operation not valid: Control 'esriMapControl' accessed from a thread other than the thread it was created on.
My code is simply this...
Me.esriToolbarControl.Dispose()
Me.esriTOCControl.Dispose()
Me.esriMapControl.Dispose()
I am also not allowed to do this...
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(esriToolbarControl.GetOcx)
Any idea how to get around this?
By the way, the Table of contents control and map control can be disposed of just fine.