Mat*_*les 5 .net c# outlook ms-office
我遇到了一段非常简单的 C# .NET 代码的问题,它应该(现在)只需检索运行 WinForms 应用程序的计算机上安装的 Office 版本号:
var oApp = new Outlook.ApplicationClass();
var outlookVersionString = oApp.Version;
Run Code Online (Sandbox Code Playgroud)
它正确实例化对象,但是当我尝试访问 Version 属性时,我得到以下信息:
{"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: Interface not registered (Exception from HRESULT: 0x80040155)."}
我在网上做了很多搜索,所以我尝试过的东西:
[HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}]只有一个 Key 存在 ( 9.6)[HKEY_CLASSES_ROOT\Interface\{00063001-0000-0000-C000-000000000046}]C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12.exe "C:\Program Files (x86)\Microsoft Office\root\Office16\MSOUTL.OLB"(失败,因为 VS2017 未附带 Regtlibv12.exe)C:\Users\uczms>c:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /TLB "C:\Program Files (x86)\Microsoft Office\root\Office16\MSOUTL.OLB"(失败,因为它is not a valid .NET Assembly)C:\Users\uczms>c:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe /TLB "C:\Program Files (x86)\Microsoft Office\root\Office16\MSOUTL.OLB"(失败,因为它is not a valid .NET Assembly)var oApp = new Outlook.Application();
var outlookVersionString = oApp.Version;
可能值得注意的是,我有一个干净的 Windows 10 Enterprise N Creators Update 和 Office 2016 / 365 ProPlus,没有安装任何以前的版本,也没有降级。
我通常不是桌面应用程序开发人员,所以虽然我掌握了其中一些库注册工具,但我绝不是专家。
小智 5
尝试“修复”您的 Microsoft Office 安装。转到“程序和功能”,选择“修改”,然后选择“在线修复”。我有同样的问题,这解决了它。
| 归档时间: |
|
| 查看次数: |
9173 次 |
| 最近记录: |