I've been looking at the VSTO libraries, mostly for the fun of it, and I noticed that there's something called Inspector
as well as InspectorClass
.
What's the difference, why is it there and how can I put it to use? (NB I'm not looking for an answer on how to code using those classes but rather what the rationale behind that certain architecture pattern is. Purely academical curiosity.)
InspectorClass
is a coclass (concrete implementation) of the Inspector
COM interface (e.g. it is a COM object with metadata + code). An Inspector
can be instantiated directly even though it exists purely as an interface definition (it actually instantiates InspectorClass
behind the scenes).
InspectorClass
can be instantiated since it represents a concrete class instance, although as VSTO added support for embedding interop types in .NET 4 - support for the *Class
usage is no longer used and serves to exist more or less for backwards compatibility.
All this to say is that you should now be using Inspector
and not InspectorClass
which can contain executable code. From MSDN blogs:
...it is safe to embed metadata but not anything that can potentially contain executable code (class types contain metadata AND code while interfaces only contain metadata)
From this statement, you can deduce that InspectorClass
contains executable code, while Inspector
does not - it is purely an interface (metadata). This means that embedding interop types does not allow support for the *Class
implementations.