Trying to check the type of some Elements if they are (ITextElement , MarkerElement)
, when i try .getType()
function it returns always "System._COM_object".
How i could get the type of an object if i don't know its type before ? because i could only detect the types that i pretend using (obj as Interface) != null
.
but for the types that i don't pretend i get always null
from (obj as Interface)
.
Any help please.
Best Answer
In ArcObjects, like other COM-based libraries, interface testing is the main way you determine the type (using that term loosely) of object you have:
Another thing you can do is, if the object implements
IPersist
, you can get its CLSID usingGetClassID
, and, from there (if desired), you can get its ProgID using the WinAPIProgIDFromCLSID
function. This is useful for cases where the object has no other indicative interfaces.Lastly, and I've never used this myself as it seems very unwieldy and potentially very slow, is to use reflection to query interface the object against every interface in an assembly to see which interfaces it supports:
(Source: Re: Getting the real COM class name)