开发者

Outlook interoperability

开发者 https://www.devze.com 2023-03-24 23:29 出处:网络
When i declare , Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();

When i declare ,

Microsoft.Office.Interop.Excel.ApplicationClass excel =
         new Microsoft.Office.Interop.Excel.ApplicationClass();

I receive errors as

'Microsoft.Office.Interop.Outlook.ApplicationClass' cannot be embedded. Use the applicable interface instead.

and

The type 'Microsoft.Office.Interop.Outlook.ApplicationClass' has no constructors defined

What is the solutio开发者_如何学Cn?


Either use the interface:

Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application() 

or disable embedding of Interop types for this assembly (References -> Microsoft.Office.Interop.Outlook (right click) -> Properties -> Set 'Embed Interop Types' to False)

More info on the why can be found here: http://blogs.msdn.com/b/mshneer/archive/2009/12/07/interop-type-xxx-cannot-be-embedded-use-the-applicable-interface-instead.aspx.


Use this:

var outlook = new Microsoft.Office.Interop.Outlook.Application();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号