Interfaces can't be instantiated but is this an exception

I'm very surprised after seeing that I actually have to Instantiate an Interface to use the Word Interoop in C#.

Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();

The Microsoft.Office.Interop.Word.Application according to what its XML documentation says is an interface:

enter image description here

How is it possible, has visual studio confused it with something else? Or what allows this interface to be instantiated?

Jon Skeet
people
quotationmark

It's because it's a COM interface. COM interfaces - and only COM interfaces - can be instantiated directly. The runtime will create an instance of the real type behind the scenes. Personally I think it's a bit ugly (and I can't find any references to it in the C# spec) but there we go.

You can actually fake this so that the C# compiler will believe your interface is a COM type without getting COM involved properly... see my related question for details.

people

See more on this question at Stackoverflow