c# - Why is it possible to create a new instance of a COM interface? -
i don't have background regarding com nor coclasses, don't quite understand why can use new
operator interface. language/framework-agnostic view, it's confusing why compiles , runs correctly:
using microsoft.office.interop.excel; public class excelprogram { static void main(string[] args) { application excel = new application(); } }
inspecting application
in visual studio 2010 shows me:
using system.runtime.interopservices; namespace microsoft.office.interop.excel { // summary: // represents entire microsoft excel application. [guid("000208d5-0000-0000-c000-000000000046")] [coclass(typeof(applicationclass))] public interface application : _application, appevents_event { } }
what going on behind scenes?
this possible com interfaces, believe. marc gravell has explanation here.
the short answer com interface can paired "default" implementation class, when "instantiate" interface you're creating instance of default implementation class. in case of application
interface in example, appears applicationclass
.
Comments
Post a Comment