1

我已经把别人的一堆东西交给我了。在这些项目中,有一个 Word 2003 加载项(VSTO 2005 SE、.NET 2.0),据报道它在 2007 年运行良好,但我们的部署环境需要 2003 年。它对于 Office 2003 的安装显然很好——没有错误,显示在添加/删除中 - 但工具栏在 Word 本身中不可用。

据说这在某人的测试环境中运行良好,但我从未见过它在我们常见的开发环境中运行。我们有一个包含 MSI 和 setup.exe 的设置/部署项目。(我尝试在 CAB 中打包东西以防万一,我已经尝试过独立安装 prereqs,没有明显区别。)

MSI,setup.exe,在 Visual Studio 中右键单击安装 setup/deploy 项目,这些方法都没有报告错误——但这些方法都没有成功在 Server 2003 上的 Word 2003 中显示工具栏。但是,如果我将 Visual Studio 指向 winword.exe 进行调试并启动项目,则会显示加载项按钮。它继续出现在后来的独立客户初创公司中。在我通过添加/删除或右键单击卸载或运行 MSI 并删除显式删除它之前,它仍可作为工具栏使用。

所以现在我不知所措——在典型的设置/部署安装期间没有发生的调试中运行会发生什么?

编辑:好的,更新。为 Word 2003 创建了一个干净的 VSTO 2005 加载项,新的加载项名称,干净的石板。在 Server 2003 和 XP Pro 上,裸项目、virgin registry 也会遇到相同的行为。我是 XP 的本地管理员,我是 2003 机器上的域管理员。

4

2 回答 2

2

以下是一些故障排除问题:

  • 您正在开发什么样的插件?共享加载项还是 VSTO?如果VSTO是哪个版本?
  • 您使用的是什么操作系统?Vista可能很棘手...
  • 在注册表中检查加载项的 LoadBehavior。您可以在

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Word\Addins\<add-in class name>\
    

    或者

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Word\Addins\<add-in classname>\
    

如果 LoadBehavior 的值为 2,则您的加载项在启动期间已被禁用。当 Word 无法实例化加载项时会发生这种情况,通常是因为加载项引发未处理的异常,或者 - 更常见的是 - 因为加载项未正确注册。

您是否检查过目标系统上是否正确安装了 VSTO 运行时?

但是,即使您使用 VSTO,对于 Word,该插件仍然看起来像一个经典的 COM 插件,它扩展了经典的 IDTExtensibility2 接口。此类加载项必须通过以下方式注册:

  • 上面两个注册表项之一,用于告诉 Word 加载项的类名以及加载行为和描述等附加信息
  • 加载项的类名必须注册在

    HKEY_CLASSES_ROOT\<add-in classname>\CSLID
    
  • 必须在下面注册正确版本的 COM 组件(其中 {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 是在 HKEY_CLASSES_ROOT\\CSLID 下指定的组件的 guid):

    HKEY_CLASSES_ROOT\CLSID\{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    

以下两个链接也可以帮助您进一步缩小问题范围:

HOWTO:对 Visual Studio 和 Office 加载项进行故障排除

Outlook COM 插件疑难解答 - 使用 ProcMon

于 2009-01-20T19:36:46.687 回答
1

编辑:对加载项程序集的完全信任最终成为修复。似乎没有比完全信任低的任何东西运行。

//

最终向 Microsoft 开了一张票,他们向我介绍了 VSTO_SUPPRESSDISPLAYALERTS:

http://msdn.microsoft.com/en-us/library/ms269003(VS.80).aspx

该值默认为 1;将其设置为 0 会提供一个弹出对话框,否则会被掩埋。

仍在研究细节,我将继续更新此线程,但现在我们终于有了前进的基础:

Could not load file or assembly 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)


************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)
File name: 'PrintTest2007, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.Security.Policy.PolicyException: Execution permission cannot be acquired.
   at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)
   at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.HandleOnlineOffline(Exception e, String basePath, String filePath)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadStartupAssembly(EntryPoint entryPoint, Dependency dependency, Dictionary`2 assembliesHash)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ConfigureAppDomain()
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadAssembliesAndConfigureAppDomain(IHostServiceProvider serviceProvider)
   at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadEntryPointsHelper(IHostServiceProvider serviceProvider)
于 2009-01-22T18:50:11.333 回答