So if I understand correctly this code from the Invoke method:pompomJuice said:Oh yea, I forgot to mention:
m_objTransformation is actually pointing to an instance of a SM3DDisplayTransformationClass object. That is why the exception is complaining about casing from SM3DDisplayTransformationClass to I3DDisplayTransformationSetup. This is legal though as
SM3DDisplayTransformationClass implements I3DDisplayTransformationSetup, or the compiler would have moaned SM3DDisplayTransformationClass by law must always be able to cast to one of its interfaces ,surely!
double d = MapObject.Instance.MapView.RotationAngle; //This line throws the exception but only if the method was called inside the Invoke below. Look for MapView's explenation below.
involves the COM object somehow but it is executed on a different thread than the main thread (where I assume the COM object was created)?
Then that's a possible cause of your problems. Accesing STA COM objects from a different thread involves marshaling/proxying. If that cannot be done for the requested interface the error manifests as if there was no interface at all.
Try moving that code in the "else" block of your Instance_MapLoaded method and see if it works.