来自 C# 的 Outlook 2007 - COM 异常,TYPE_E_LIBNOTREGISTERED [英] Outlook 2007 from C# - COM exception, TYPE_E_LIBNOTREGISTERED
问题描述
我正在尝试制作一个可以打开新 Outlook 2007 消息的程序.
I'm trying to make a program that would open new Outlook 2007 message.
我从 COM 选项卡中引用了 Microsoft Outlook 12.0 ObjectLibrary.
I've referenced from COM tab Microsoft Outlook 12.0 ObjectLibrary.
这些项目出现在 VS 中的引用中:
These items showed up in references in VS:
Microsoft.Office.Core
Microsoft.Office.Inerop.Outlook
现在我尝试调用以下代码:
Now I try to invoke following code:
var _outlookInstance = new Microsoft.Office.Interop.Outlook.Application();
var _message = (OutlookApp.MailItem)_outlookInstance.CreateItem(OutlookApp.OlItemType.olMailItem);
其中 OutlookApp==Microsoft.Office.Interop.Outlook 命名空间.
where OutlookApp==Microsoft.Office.Interop.Outlook namespace.
在调用清单的第二行时,我不断收到此异常:(InvalidCastException)
While invoking second line of listing I keep getting this exception: (InvalidCastException)
无法转换 COM 类型的对象'Microsoft.Office.Interop.Outlook.ApplicationClass'接口类型'Microsoft.Office.Interop.Outlook._Application'.此操作失败,因为COM 上的 QueryInterface 调用带有 IID 的接口组件'{00063001-0000-0000-C000-000000000046}'由于以下错误而失败:图书馆未注册.(来自 HRESULT 的异常:0x8002801D(TYPE_E_LIBNOTREGISTERED)).
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: Library unregistered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
该代码在我的其他工作站上运行良好,适用于 Outlook 2003.
That code worked well for Outlook 2003 on my other station.
如果有任何解决方法的想法,我将不胜感激.
I'll be grateful for any ideas how to solve it.
推荐答案
当您卸载了 office 2013 安装并返回到 office 2010 时,也会发生这种情况.可能存在一些注册表项和 dll,导致 Office 应用程序加载错误的 dll.
This can also happen, when you have uninstalled an office 2013 installation and you return to office 2010. There might be some registry keys and dlls left, which cause the office application to load the wrong dll(s).
这里是修复:http://www.fieldstonsoftware.com/support/support_gsyncit_2013.shtml
这篇关于来自 C# 的 Outlook 2007 - COM 异常,TYPE_E_LIBNOTREGISTERED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!