在使用REGASM& G时,不在GAC中的程序集的多个搜索路径。 COM [英] Multiple search paths for assemblies not in the GAC when using REGASM & COM

查看:231
本文介绍了在使用REGASM& G时,不在GAC中的程序集的多个搜索路径。 COM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个.NET程序集,该程序集将被注册为COM,以便它可以被Microsoft Excel VBA引用。

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.

程序集引用了第三方.NET程序集(包含一些有用的类),但是,我有一个问题,我的程序集的部署,因为第三方程序集的路径并不总是在同一位置(它取决于用户的区域设置以及第三方程序集的安装时间。)

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).

这意味着在部署我的程序集(使用REGASM)时,安装它的系统,REGASM有时会崩溃,因为它找不到我的程序集对第三方程序集的依赖。

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.

理想情况下,我想使用早期绑定在我的程序集,但如果我这样做,并且第三方程序集的路径与Visual Studio中的引用不一样,那么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.

复制本地(在VS中)将解决这个问题,但由于第三方程序集有时打补丁,所以我不希望保持在与我的程序集相同的文件夹中的过期版本。

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.

有没有办法,使我不必使用复制本地?我想我可以使用某种动态负载的第三方程序集,但是仍然可以使用早期绑定? (并且REGASM会工作吗?)

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?)

推荐答案

为什么不使用复制本地首次使用,应用程序启动,通过一个可能的位置的列表,其中较新的版本可能和覆盖(或不可访问等时调度覆盖)本地程序集如果可能的话。

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.

此外,您可能希望为用户提供一个选项,以手动设置应打开dll的位置,然后始终(或按需)检查是否有较新的版本。

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.

另一个方面是,为什么要更新新的程序集,如果你的应用程序的功能取决于某个版本,因为如果他们改变了一个feauture或者他们efed了什么,你的程序将失败,因为更新,只是一个思想。

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.

这篇关于在使用REGASM& G时,不在GAC中的程序集的多个搜索路径。 COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆