I'm working with MS Excel interop in C# and I don't understand how this particular line of code works:
var excel = new Microsoft.Office.Interop.Excel.Application();
where Microsoft.Office.Interop.Excel.Application is an INTERFACE defined as:
[Guid("000208D5-0000-0000-C000-000000000046")]
[CoClass(typeof(ApplicationClass))]
public interface Application : _Application, AppEvents_Event
{
}
I'm thinking that some magic happens when the interface is decorated with a CoClass attribute, but still how is it possible that we can create an instance of an interface with a new keyword? Shouldn't it generate a compile time error?
Ayende blogged about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With