Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is it I am able to create a new instance of interface Microsoft.Office.Interop.Word.Application

According to the Word Interop documentation Microsoft.Office.Interop.Word.Application is an interface, yet I am able to create a new instance of it as follows

var application = new Microsoft.Office.Interop.Word.Application();

There's also an example of this on DotNetPerls. It's normally not possible to create instances of an interface in C#, so how is it possible here? Is this a feature of COM or dynamic types?

like image 754
Dan Stevens Avatar asked Dec 07 '25 19:12

Dan Stevens


1 Answers

Because this is not C# interface but a COM interface. COM interfaces are represented in C# as interfaces with ComImport and Guid attributes.

[GuidAttribute("00020970-0000-0000-C000-000000000046")]
public interface Application : _Application, 
    ApplicationEvents4_Event
like image 61
vendettamit Avatar answered Dec 09 '25 16:12

vendettamit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!