【发布时间】:2022-06-15 22:59:19
【问题描述】:
我创建了一个 VSTO Outlook 插件,它在使用 ClickOnce 部署和通过 ClickOnce 生成的 Setup.exe 安装时工作正常。现在,我已经使用 Wix 为它创建了一个 MSI。我正在使用批处理文件在注册表中添加 vsto:
@echo off
setlocal enabledelayedexpansion
%SystemRoot%\system32\reg.exe ADD "HKCU\Software\Microsoft\Office\Outlook\Addins\MyPlugin" /v "FriendlyName" /t REG_SZ /d "MyPlugin"
%SystemRoot%\system32\reg.exe ADD "HKCU\Software\Microsoft\Office\Outlook\Addins\MyPlugin" /v "Manifest" /t REG_SZ /d "file:///C:/Program Files (x86)/MyPlugin/MyPlugin.vsto"
%SystemRoot%\system32\reg.exe ADD "HKCU\Software\Microsoft\Office\Outlook\Addins\MyPlugin" /v "Description" /t REG_SZ /d "MyPlugin"
%SystemRoot%\system32\reg.exe ADD "HKCU\Software\Microsoft\Office\Outlook\Addins\MyPlugin" /v "LoadBehavior" /t REG_DWORD /d 3
endlocal
当我运行 msi 时,此注册表项已按预期添加。
但是当我加载 Outlook 插件时,它处于非活动状态。 LoadBehavior 值从 3 变为 2。在 Outlook 应用程序中,LoadBehavior 为Not Loaded. A runtime error ocurred during the loading of the COM Add-in。
VSTO 日志中记录的文本/问题:
Log entry added at 10:20:28 AM:
-----------Caption----------------
Microsoft Office Application Add-In
-----------Message----------------
An add-in could not be found or could not be loaded.
-----------Details----------------
Could not load file or assembly 'MyPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=73e9e1c2746dd019' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'MyPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=73e9e1c2746dd019' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
File name: 'MyPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=73e9e1c2746dd019'
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)
查看 EventViewer 时,出现 VSTO4.0 错误
This event is not displayed correctly because the underlying XML is not well formed. Below is the raw text of the event.
4096200x80000000000000265553<User machine name>Customization URI: file:///C:/Program Files (x86)/Common Files/Microsoft Shared/VSTA/Pipeline.v10.0/PipelineSegments.store Exception: Exception reading manifest from
file:///C:/Program%20Files%20(x86)/Common%20Files/Microsoft%20Shared/VSTA/Pipeline.v10.0/PipelineSegments.store: the manifest may not be valid or the file could not be opened.
************** Exception Text ************** System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from
file:///C:/Program%20Files%20(x86)/Common%20Files/Microsoft%20Shared/VSTA/Pipeline.v10.0/PipelineSegments.store: the manifest may not be valid or the file could not be opened. --->
System.Xml.XmlException: '', hexadecimal value 0x01, is an invalid character. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar) at
System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Deployment.Application.ManifestValidatingReader.XmlFilteredReader.Read() at
System.Xml.XsdValidatingReader.Read() at
System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType
manifestType, Uri sourceUri) --- End of inner exception stack trace --- at
Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(
TimeSpan timeout) at
Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn() ************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.9151 (WinRelRS6.050727-9100) CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll ---------------------------------------- Microsoft.VisualStudio.Tools.Office.Runtime.v10.0 Assembly Version: 10.0.0.0 Win32
Version: 10.0.60828.0 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0/10.0.0.0__b
03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.v10.0.dll ----------------------------
------------ System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.9147 (WinRelRS6.050727-
9100) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll -
--------------------------------------- System.Core Assembly Version: 3.5.0.0 Win32 Version:
3.5.30729.9135 built by: WinRelRS6 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll -------
--------------------------------- Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0 Assembly
Version: 10.0.0.0 Win32 Version: 10.0.60828.0 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0/10.0.
0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.v10.0.dll ----------------
------------------------ System.AddIn Assembly Version: 3.5.0.0 Win32 Version: 3.5.30729.9135
built by: WinRelRS6 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.AddIn/3.5.0.0__b77a5c561934e089/System.AddIn.dll -----
----------------------------------- Microsoft.Office.Tools.Outlook.v9.0 Assembly Version: 9.0.0.0
Win32 Version: 9.0.30729.7079 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Tools.Outlook.v9.0/9.0.0.0__b03f5f7f11d50a3a
/Microsoft.Office.Tools.Outlook.v9.0.dll ----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0 Assembly Version: 10.0.0.0 Win32 Version:
10.0.60828.0 CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0/10.0.
0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.v10.0.dll ----------------
------------------------ System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version:
2.0.50727.9136 (WinRelRS6.050727-9100) CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows
.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32
Version: 2.0.50727.9136 (WinRelRS6.050727-9100) CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll -
--------------------------------------- System.Deployment Assembly Version: 2.0.0.0 Win32 Version:
2.0.50727.9136 (WinRelRS6.050727-9100) CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Deployment/2.0.0.0__b03f5f7f11d50a3a/System.Deployment
我试图从Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Resiliency\DisabledItems 中删除所有项目,但我的 Outlook 插件仍然没有加载。
我花了很多时间尝试不同的解决方法,但都没有奏效。请帮助我如何解决此问题并成功加载 vsto 插件?
【问题讨论】:
-
您可以在记事本中打开您的 VSTO 文件以验证它没有损坏吗?
-
是的,我可以在记事本中打开 vsto
-
看起来还可以吗?
-
这是一个 XML 文件,每个标签中分配的值看起来都很好。
-
文件看起来和预期的一样。如果你能告诉我应该寻找哪个标签,我可以在这里分享。我不太了解 vsto 和清单文件
标签: outlook vsto outlook-addin