C# - How to test at runtime which COM coclass was used to instantiate an interface?
问题 Suppose you have a COM interface ICOMInterface that is implemented by coclasses Coclass1 and Coclass2 . Neither of these coclasses have interfaces of their own (for simplicity's sake and to illustrate my issue). In C#, you can create an instance of a COM interface from a coclass like so: ICOMInterface myComInterface = new Coclass1(); Now, how can you determine whether myComInterface was instantiated by Coclass1 or Coclass2 ? Using the "is" statement like follows always returns true, and as