.NET Word 2003 加载项可以安装在 GAC 之外吗?
我创建了一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以手动运行以下命令来设置安全性,以允许单词从 GAC 外部运行程序集。 这将创建一个具有完全信任的新组,从而允许程序集运行。
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.
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.
您绝对不必将程序集安装到 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:
根本不需要 VS 2005 的另一种选择是:
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:
Another option where you don't need VS 2005 at all would be:
我不认为将附加程序集放入 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