.NET app.config问题 [英] .NET app.config question
问题描述
我创建了一个使用CLR 2.0的Excel 2003加载项,并且该加载项将安装在客户站点的数百台计算机上。问题是,一些安装加载项的机器有并行运行的.NET 1.1和.NET 2.0,并且插件在尝试加载时会抛出错误。
I have created an Excel 2003 add-in that uses the CLR 2.0 and this add-in is to be installed in hundreds of machines at my customer's site. The issue is that some of the machines where the add-in is installed have .NET 1.1 and .NET 2.0 running side by side, and the plugin throws an error when it's trying to load.
我遇到的解决方案是在同一文件夹中创建一个excel.exe.config文件,其中excel.exe是设置supportedRuntime版本为v2。 0.50727。
The solution I have come across that works is to create an excel.exe.config file in the same folder where excel.exe is that sets the supportedRuntime version to v2.0.50727.
因为此解决方案在我的情况下不能很好地扩展(因为加载项将在数百台计算机上使用,用户甚至可能无法创建配置文件),我想知道是否可以在我的插件app.config文件中添加相同的supportedRuntime参数,它会工作。
Because this solution does not scale well in my case (since the add-in is to be used in hundreds of machines where the users might not even have access to create a config file), I was wondering if I could add the same supportedRuntime parameter in my plugin app.config file and it would work.
如果这不行,你知道我可以尝试什么吗?
If this will not work, do you guys know of anything else I could try?
推荐答案
您收到的错误讯息是什么?
What is the error message that you receive?
您描述的问题不应该发生在Office 2007.但是,这是一个已知的问题所谓的共享加载项使用COM互操作性的Extensibility.IDTExtensibility2接口)。
The problem that you describe should not occur with Office 2007. However, it is a known problem for so-called Shared Add-ins (.NET add-ins based on the Extensibility.IDTExtensibility2 interface using COM interoperability) in Office 2003.
Microsoft发布了一个补丁,该补丁应该为使用该加载项的每个用户安装。您可以在这里获取补丁:
Microsoft has a released a patch, which should be installed for every user using the add-in. You can obtain the patch here:
使用配置的解决方案文件是一个非标准的解决方案,但也应该解决下面的文章中所述的问题:
The solution using the config file is a non-standard solution but should also fix the problem as stated in the following article:
如果要使用MSI安装程序部署加载项,您应该检查 Microsoft .NET Framework 2.0(KB908002)的共享加载项支持更新 - 安装项目属性中的必备项。请注意,只能为当前用户安装此修复程序,即应禁用ALLUSERS设置。
If want to deploy your add-in using an MSI installer you should check the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002) as a pre-requisite in the properties of the setup project. Please note that this fix can only be installed for the current user, i.e. an ALLUSERS setup should be disabled.
更新:使用VS 2008的安装有点复杂。请参阅这里:
UPDATE: The installation with VS 2008 is a little more complicated. See here:
这篇关于.NET app.config问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!