Outlook互操作性

Tra*_*tor 10 c# outlook

当我宣布时,

Microsoft.Office.Interop.Excel.ApplicationClass excel =
         new Microsoft.Office.Interop.Excel.ApplicationClass();
Run Code Online (Sandbox Code Playgroud)

我收到的错误是

无法嵌入"Microsoft.Office.Interop.Outlook.ApplicationClass".请改用适用的界面.

和

类型'Microsoft.Office.Interop.Outlook.ApplicationClass'没有定义构造函数

解决办法是什么?

小智 17

使用界面:

Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application() 
Run Code Online (Sandbox Code Playgroud)

或禁用此程序集的Interop类型的嵌入(引用 - > Microsoft.Office.Interop.Outlook(右键单击) - >属性 - >将'嵌入互操作类型'设置为False)

有关原因的更多信息,请访问:http://blogs.msdn.com/b/mshneer/archive/2009/12/07/interop-type-xxx-cannot-be-embedded-use-the-applicable- interface-instead.aspx.