64位Outlook无法加载VSTO加载项问题求助
VSTO加载项在64位Outlook中无法加载的排查方案
我开发的VSTO加载项在32位Outlook(无论运行于32位还是64位Windows系统)中可正常工作,但安装到装有64位Outlook的机器上时无法加载。直接从Visual Studio运行加载项时捕获的错误信息如下:
无法加载文件或程序集“MyAdd-in, Version=23.2.15.0, Culture=neutral”或其某一个依赖项。给定的程序集名称或代码库无效。(异常来自 HRESULT: 0x80131047) ************** 异常文本 ************** System.IO.FileLoadException: 无法加载文件或程序集“MyAdd-in, Version=23.2.15.0, Culture=neutral”或其某一个依赖项。给定的程序集名称或代码库无效。(异常来自 HRESULT: 0x80131047) 文件名称: 'MyAdd-in, Version=23.2.15.0, Culture=neutral' 在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) 在 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 在 System.Reflection.Assembly.Load(String assemblyString) 在 Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String entryPointTypeName) 在 Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.LoadEntryPoints(IntPtr serviceProvider) ************** 已加载程序集 ************** mscorlib 程序集版本: 4.0.0.0 Win32 版本: 4.8.9139.0 built by: NET481REL1LAST_B 代码库: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Office.Runtime 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.dll ---------------------------------------- System.Core 程序集版本: 4.0.0.0 Win32 版本: 4.8.9139.0 built by: NET481REL1LAST_B 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System 程序集版本: 4.0.0.0 Win32 版本: 4.8.9139.0 built by: NET481REL1LAST_B 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Configuration 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- System.Security 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Hosting 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Runtime 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll ---------------------------------------- System.Deployment 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Deployment/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.ServerDocument 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ---------------------------------------- System.Windows.Forms 程序集版本: 4.0.0.0 Win32 版本: 4.8.9075.0 built by: NET481REL1LAST_C 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Xml.Linq 程序集版本: 4.0.0.0 Win32 版本: 4.8.9032.0 built by: NET481REL1 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll ---------------------------------------- Microsoft.Office.Tools 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.dll ---------------------------------------- Microsoft.Office.Tools.Outlook.Implementation 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Outlook.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Outlook.Implementation.dll ---------------------------------------- Microsoft.Office.Tools.Common.Implementation 程序集版本: 10.0.0.0 Win32 版本: 10.0.60828.0 代码库: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.Implementation.dll ----------------------------------------
排查建议
检查项目平台目标设置
确认Visual Studio中加载项项目的平台目标是否设置为Any CPU(取消勾选“首选32位”)或x64。32位编译的程序集无法在64位进程(64位Outlook)中加载。操作路径:右键项目→属性→生成→平台目标。验证依赖项的位数兼容性
错误提示无法加载程序集或其依赖项,需逐一检查所有引用的第三方库:- 查看库的官方文档或属性,确认是否支持64位;
- 使用
dumpbin /headers <dll路径>命令检查依赖库的目标架构,排除仅32位的库; - 将仅32位的依赖替换为64位兼容版本。
检查注册表项的位数匹配
VSTO加载项的注册表路径因Outlook位数不同而区分:- 32位Outlook(含64位Windows上的32位Outlook):
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Office\Outlook\Addins\<你的加载项ID> - 64位Outlook:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlook\Addins\<你的加载项ID>
确认安装程序在64位系统上是否正确写入对应路径的注册表项,且Manifest、Assembly等字段指向正确的64位程序集路径。
- 32位Outlook(含64位Windows上的32位Outlook):
核对程序集强名称与注册信息
错误中提到“程序集名称或代码库无效”,需确认:- 程序集的强名称(版本、公钥标记等)与注册表中
Assembly字段的定义完全一致; - 若使用ClickOnce部署,确保部署清单中的程序集信息与实际编译产物匹配;
- 重新生成程序集并更新注册信息。
- 程序集的强名称(版本、公钥标记等)与注册表中
启用程序集绑定日志排查
使用fuslogvw.exe(程序集绑定日志查看器)捕获详细加载失败原因:- 以管理员身份运行
fuslogvw.exe; - 点击“设置”,选择“记录所有绑定失败到磁盘”;
- 重启Outlook触发加载失败;
- 返回查看日志,定位具体是哪个依赖项加载失败,或路径、版本不匹配问题。
- 以管理员身份运行
确认VSTO运行时版本兼容性
检查64位机器上是否安装了对应版本的VSTO运行时。日志中显示使用的是Microsoft.VisualStudio.Tools.Office.Runtime版本10.0.0.0,需确保系统安装了**Microsoft Visual Studio 2010 Tools for Office Runtime(x64)**或更高版本的兼容运行时。
内容的提问来源于stack exchange,提问作者Max Headroom
相关产品推荐
相关产品推荐

