.NET Word 2003 加载项可以安装在 GAC 之外吗?

发布于 2024-07-13 07:57:56 字数 486 浏览 6 评论 0原文

我创建了一个 Word 加载项组件和一个用于安装该组件的 Visual Studio 安装项目。

在安装了 Office 2003 的干净计算机上,似乎无法在 Word 中加载加载项组件。

谷歌搜索该问题表明这是因为该程序集不受信任。 我使用命令行工具给予程序集完全信任:

caspol -af AssemblyName.dll

这没有什么区别,并且组件仍然没有加载到 Word 中。 caspol 打印出一条消息“由于所有 GAC 程序集始终获得完全信任,因此完全信任列表不存在” 更有意义。 您应该安装安全中使用的任何程序集 更改安装程序以将程序集放入 GAC中,

使其能够在 Word 中正确加载。但是该组件将来可能必须使用通用程序集,在我们的其他 . NET 应用程序,并且将这些库添加到 GAC 中是不受欢迎的。

有谁知道如何设置安全性以允许在 GAC 外部安装组件时加载该组件?

I've created a Word add-in component, and a visual studio setup project to install the component.

On a clean machine with Office 2003 installed, it does not seem to be possible to get the add-in component to load in Word.

Googling the issue suggests that this is because the assembly is not trusted. I gave the assembly full trust using the command line tool:

caspol -af AssemblyName.dll

This makes no difference and the compenent is still not loaded in Word. caspol prints out a message "Because all GAC assemblies always get full trust, the full trust list is no
longer meaningful. You should install any assemblies that are used in security
policy in the GAC to ensure they are trusted"

Changing the installer to put the assembly in the GAC allows it to correctly load in Word. But the component may have to use common assemblies in the future, shared between our other .NET applications, and adding these libraries to the GAC would be undesirable.

Does anyone know how to set the security to allow the component to be loaded when installed outside the GAC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走过海棠暮 2024-07-20 07:57:56

您可以手动运行以下命令来设置安全性,以允许单词从 GAC 外部运行程序集。 这将创建一个具有完全信任的新组,从而允许程序集运行。

caspol.exe -u -addgroup All_Code -url "\*"  FullTrust -n AssemblyName.dll

Microsoft 在以下站点提供了安装程序的示例自定义操作MSDN 链接,这将允许您将此命令作为安装程序自定义操作包含在内。

You can manually run the following command to set security to allow the word to run the assembly from outside the GAC. This creates a new group with full trust which is what allows the assembly to run.

caspol.exe -u -addgroup All_Code -url "\*"  FullTrust -n AssemblyName.dll

Microsoft have an example custom action for an installer at the following site link to MSDN, which will allow you to include this command as an installer custom action.

情归归情 2024-07-20 07:57:56

您绝对不必将程序集安装到 GAC,也不必在外接程序集中定义任何安全策略。

您是否在 Office 2003 中使用 .NET 2.0? Office 2003 和 Office XP 在加载 .NET 2.0 插件时都存在问题。 它们使用 .NET 1.1 Framework 加载(如果机器上存在,这很可能)。 因此,您需要使用Microsoft .NET 的共享加载项支持更新来修补您的 Office 安装框架 2.0 (KB908002)

您绝对应该将此补丁包含在安装程序的先决条件中。

此问题的答案中查找更多详细信息。

当然,您必须在目标系统上安装正确版本的 PIA(几乎忘记了这一点,错误或丢失的 PIA 是加载项无法加载的主要问题之一)。

更新:KB908002 需要在 PC 上安装 VS 2005,才能将共享插件支持更新添加到安装项目的先决条件对话框中。 在这种情况下,必须使用以下解决方法:

如果您使用的是 Visual Studio 2008,则必须遵循 解决方法添加先决条件对话框下列出了 KB908002:

  1. 在安装了 Visual Studio 2005 的计算机上下载并安装修复程序。
  2. 导航至C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages,找到 KB908002 文件夹。
  3. 登录到安装了 Visual Studio 2008 的计算机,并将 KB908002 文件夹复制到C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
  4. 现在,如果您转到 Visual Studio 2008 计算机上的先决条件列表,您将看到列出的修复程序。

根本不需要 VS 2005 的另一种选择是:

  1. 将修复程序下载到临时文件夹。
  2. 打开命令提示符,导航到修复程序所在的文件夹,然后启动以下命令以从自解压安装文件中提取文件:

    <前><代码>vs2005-kb908002-enu-x86.exe /C /T:C:\KB908002\
    光盘\KB908002

    现在文件夹 C:\KB908002 将包含三个文件,vs2005-kb908002-enu-x86.exe /C /T:C:\tmp\KB908002\tmp、setup.exe 和 bootstrapper.msi

    < /里>

  3. 我们对 bootstapper.msi 的内容感兴趣,因此我们提取该文件的内容:

    msiexec /a bootstrapper.msi /qb TARGETDIR=C:\KB908002\tmp\ 
      cd tmp 
      
  4. 最后,我们将解压的packages文件夹复制到Windows SDK的bootstrapper文件夹

    xcopy /E“C:\KB908002\tmp\SDK\BootStrapper\Packages”“C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages” 
      
  5. 现在,如果您转到 Visual Studio 2008 中的先决条件列表,您将看到列出的修复程序。

You definitely do not have to install your assembies to the GAC, neither is it necessary to define any security policy on your add-in assembly.

Are you using .NET 2.0 with Office 2003? Office 2003 and Office XP both have an issue loading .NET 2.0 addins. They get loaded using the .NET 1.1 Framework (if present on the machine, which is very likely). You therefore need to patch your Office installation with the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002).

You should definitely include this patch to the pre-requisites of your installer.

Find more details in the answer to this questions.

And of course, you must have the correct version of the PIAs installed on your target system (almost forgot this point, wrong or missing PIAs is one of the main problems why add-ins won't load).

Update: KB908002 requires VS 2005 on the PC in order to add the Shared Add-in Support Update to the pre-requisites dialog of the setup projects. The following workaround must be used in this case:

If you are using Visual Studio 2008 then you have to follow the workaround mentioned below to get KB908002 listed under add pre-requisites dialog:

  1. Download and install the fix on a machine which has Visual Studio 2005 installed.
  2. Navigate to C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages, locate KB908002 folder.
  3. Log on to the machine which has Visual Studio 2008 installed and copy KB908002 folder to C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
  4. Now, if you go to pre-requisites list on Visual Studio 2008 machine you would see the fix listed.

Another option where you don't need VS 2005 at all would be:

  1. Download the fix to a temporary folder.
  2. Open a command prompt, navigate to the folder where the fix is located and launch the following command to extract the files from the self-extracting installation file:

    vs2005-kb908002-enu-x86.exe /C /T:C:\KB908002\
    cd \KB908002
    

    Now the folder C:\KB908002 will contain three files, vs2005-kb908002-enu-x86.exe /C /T:C:\tmp\KB908002\tmp, setup.exe and bootstrapper.msi

  3. We are interested in the contents of bootstapper.msi, so we extract the content of this file:

    msiexec /a bootstrapper.msi /qb TARGETDIR=C:\KB908002\tmp\
    cd tmp
    
  4. Finally, we copy the packages folder that we extracted to the bootstrapper folder of the Windows SDK

    xcopy /E "C:\KB908002\tmp\SDK\BootStrapper\Packages" "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages"
    
  5. Now, if you go to pre-requisites list in Visual Studio 2008 you would see the fix listed.

时光沙漏 2024-07-20 07:57:56

我不认为将附加程序集放入 GAC 中是强制性的。 我认为您只是在部署中缺少一个步骤。

MS Word 等办公应用程序通过读取某些注册表项来加载其加载项。 您很可能不会在部署期间创建这些条目。

要了解所有此类注册表业务的详细信息,请参阅这篇文章。 另要了解有关部署 Office 加载项的一般信息,请参阅 这篇文章

I don't think putting the add-in assembly in GAC is compulsory. I think you're just missing a step in your deployment.

The office applications such as MS Word load their add-ins by reading certain registry entries. You are most likely not creating these entries during deployment.

To learn the details of all this registry business, see this article. Also to read about deploying office add-ins in general, see this article

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文