VSTO Word加载项新安装后无法运行,求助排查解决
问题:Word VSTO加载项程序集加载失败(FileNotFoundException)
多款此前可正常安装运行的Word VSTO加载项,现在使用相同安装文件均出现运行时错误。为排查问题,使用Word VSTO加载项模板创建新项目(配置:.Net 4.8、Any CPU、Word 2304、Visual Studio 17.7.6),调试时触发如下错误:
Could not load file or assembly 'WordAddIn1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. ************** Exception Text ************** System.IO.FileNotFoundException: Could not load file or assembly 'WordAddIn1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'WordAddIn1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileNotFoundException: Could not load file or assembly 'WordAddIn1, Version=1.0.0.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified. File name: 'WordAddIn1, Version=1.0.0.0, Culture=neutral' === Pre-bind state information === LOG: DisplayName = WordAddIn1, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: WordAddIn1, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL | Domain ID: 2 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/Users/jzhou/source/repos/WordAddIn1/WordAddIn1/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/jzhou/source/repos/WordAddIn1/WordAddIn1/bin/Debug/WordAddIn1.DLL. LOG: No application configuration file found. LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). ERR: Failed to complete setup of assembly (hr = 0x80070002). Probing terminated. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String entryPointTypeName) at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.LoadEntryPoints(IntPtr serviceProvider) ************** Loaded Assemblies ************** mscorlib Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Office.Runtime Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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 ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Hosting Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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 ---------------------------------------- System Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Configuration Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Core Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Security Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll ---------------------------------------- System.Xml Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Applications.Runtime Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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 Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: 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 Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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 Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Xml.Linq Assembly Version: 4.0.0.0 Win32 Version: 4.8.9037.0 built by: NET481REL1 CodeBase: 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 Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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.Word.Implementation Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Word.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Word.Implementation.dll ---------------------------------------- Microsoft.Office.Tools.Common.Implementation Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: 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 ---------------------------------------- Microsoft.Office.Tools.Common Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll ---------------------------------------- Microsoft.Office.Tools.Word Assembly Version: 10.0.0.0 Win32 Version: 10.0.60910.0 CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Word/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Word.dll ----------------------------------------
该问题存在于所有调试项目及已发布版本的安装过程中,已尝试以下方案但均未解决:
- 重建解决方案
- 在同事机器上重建项目
- 全新虚拟机中重新安装Visual Studio 2022和VSTO
- 在不同版本Word(2304、2208、2102,含64位/32位)及不同电脑上安装加载项
- 更换自签名代码证书
当前仅在Word 2022版本的VDI环境中可正常安装运行加载项,但VDI会在用户注销后重置数据。此外,此前已安装加载项的用户未出现问题,仅新安装时触发错误。怀疑是环境变更导致,寻求解决思路。
内容的提问来源于stack exchange,提问作者John
相关产品推荐
相关产品推荐

