Outlook互操作异常 [英] Outlook Interop Exception
问题描述
尝试将Outlook自动化为
Trying to automate Outlook as
Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
并在第二行即GetNamespace
无法转换类型为COM的对象 'Microsoft.Office.Interop.Outlook.ApplicationClass'到接口类型 'Microsoft.Office.Interop.Outlook._Application'.这项作业 失败,因为对COM组件的QueryInterface调用 IID'{00063001-0000-0000-C000-000000000046}'的接口失败 由于以下错误:不支持此类接口(异常 从HRESULT:0x80004002(E_NOINTERFACE)).
Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
我正在使用.Net Framework 4
和Outlook 2013
.
这是唯一的解决方案!!!因为我正努力避免对注册表进行任何更改.
Is this the only solution!!! as I am trying to avoid making any changes to the registry.
修改
此没有解决问题.
修改 如果引用的库是Office 15,而已安装的库是10或12,则可以使用吗?
Edit If the referenced library is Office 15 and the installed library is 10 or 12, would it work?
推荐答案
这个问题困扰了我好几天了.这对我有用:
I've been stumped by this problem for days. This worked for me:
我刚刚意识到Outlook 2013是64位...,而我的C#应用程序已在项目属性"中->构建任何CPU"作为平台目标,并在首选32位"中打勾.
I just realized that Outlook 2013 is 64 bit... And my C# app had in Project Properties -> Build "Any CPU" as platform target and a check-mark in "Prefer 32-bit".
我将平台目标更改为x64,并且可以正常工作!
I changed the Platform target to x64 and it worked!
这篇关于Outlook互操作异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!