Knoche

SetBuddyControl error : specified cast is not valid

Discussion created by Knoche on May 12, 2011
I'm a bit new to the ArcEngine programming (but not AO) and I've just ported a poorly organized .sln into a new one, reorganizing namespaces and such but not really changing any code.

Now, I get "Specified cast is not valid" when trying to set a TOC's buddy control to an subclass of AxMapControl.  I'm able to successfully cast the custom control to AxMapControl so I feel like the underlying issue is not there.

Also, after looking at the exception that it's throwing I notice that the actual error is coming from

Marshal.GetIDispatchForObject(_mapControl);

Outcomes