9
我没有太多关于COM和coclasses的背景,所以我不太明白为什么我可以使用带接口的new
运算符。从语言/框架无关的观点,它的迷惑,为什么这个编译并运行正常:为什么可以创建一个COM接口的新实例?
using Microsoft.Office.Interop.Excel;
public class ExcelProgram
{
static void Main(string[] args)
{
Application excel = new Application();
}
}
在Visual Studio 2010中检查Application
显示我:
using System.Runtime.InteropServices;
namespace Microsoft.Office.Interop.Excel
{
// Summary:
// Represents the entire Microsoft Excel application.
[Guid("000208D5-0000-0000-C000-000000000046")]
[CoClass(typeof(ApplicationClass))]
public interface Application : _Application, AppEvents_Event
{
}
}
这是怎么回事幕后?
谢谢。该链接有链接到http://stackoverflow.com/questions/1093536/how-does-the-c-compiler-detect-com-types。猜猜我在搜索错误的关键字 - 看起来像我的问题本质上是重复的。 – ide 2011-02-09 23:43:50