简体   繁体   English

使用REGASM&COM时,GAC不在的程序集的多个搜索路径

[英]Multiple search paths for assemblies not in the GAC when using REGASM & COM

I am in the process of creating a .NET assembly that will be registered for COM so that it can be referenced by Microsoft Excel VBA. 我正在创建一个将为COM注册的.NET程序集,以便Microsoft Excel VBA可以引用它。

The assembly references a third-party .NET assembly (that contains some useful classes) that is not in the GAC, however, I have a problem with the deployment of my assembly since the path to the third-party assembly is not always in the same location (it depends on the locale of the user as well as how recently the third-party assembly was installed). 该程序集引用了不在GAC中的第三方.NET程序集(包含一些有用的类),但是,我的程序集部署存在问题,因为指向第三方程序集的路径并不总是在相同的位置(取决于用户的语言环境以及第三方程序集的最新安装时间)。

This means that when deploying my assembly (using REGASM), depending on the system that it's being installed on, REGASM will sometimes fall over as it could not find my assembly's dependency on the third-party assembly. 这意味着在部署我的程序集(使用REGASM)时,根据其安装所在的系统,REGASM有时会崩溃,因为它找不到我的程序集对第三方程序集的依赖。

Ideally I would like use early binding in my assembly, but if I do this and the path to the third-party assembly is not the same as the reference in Visual Studio then REGASM will fail. 理想情况下,我想在程序集中使用早期绑定,但是如果我这样做并且第三方程序集的路径与Visual Studio中的引用不同,则REGASM将失败。

I realise that "Copy Local" (in VS) would solve this, but as the third-party assembly is sometimes patched then I don't really wish to keep an out of date version of it in the same folder as my assembly. 我意识到“复制本地”(在VS中)可以解决此问题,但是由于有时会修补第三方程序集,因此我真的不希望将其过时的版本保留在与我的程序集相同的文件夹中。

Is there a way around this so that I don't have to use "Copy Local"? 有没有一种解决方法,这样我就不必使用“本地复制”了? I suppose that I could use some kind of dynamic load of the third-party assembly, but then could still use early binding? 我想我可以使用某种形式的第三方程序集的动态负载,但是仍然可以使用早期绑定吗? (and would REGASM work?) (REGASM会起作用吗?)

Why not use the 'Copy local' for first use, and have a routine on the application startup that goes thru a list of possible locations where the newer version might be and override (or schedule an override when not accessible etc.) the local assembly if possible. 为什么不首先使用“复制本地”,并在应用程序启动时有一个例程,该例程会列出较新版本可能存在的位置列表,并覆盖(或在无法访问时安排覆盖)等。如果可能的话。

Also, you might want to give the user an option to manually set a location where the dll should be opened from then you always (or on demand) check for newer versions. 此外,您可能希望为用户提供一个选项,以手动设置从其开始打开dll的位置,然后您始终(或按需)检查较新的版本。

Another aspect is, why would you want to update the new assembly if your application's functionality depends on a certain version, since if they changed a feauture or what ever they efed up something you're program will fail because of the update, just a thought. 另一个方面是,如果您的应用程序的功能取决于特定版本,为什么还要更新新的程序集,因为如果他们更改了功能,或者他们厌倦了您正在编写的程序,由于更新将失败,这只是一个想法。 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM