如果程序集被添加到 GAC 中,它引用的所有程序集是否也需要添加到那里?

发布于 2024-10-01 05:20:47 字数 1324 浏览 1 评论 0原文

背景信息

我在远程服务器上有两个基于 .NET 程序集的 COM+ 组件,其中一个组件调用另一个组件,而另一个组件又调用私有组件。

我的调用链看起来像这样;

客户端机器:

测试工具 ->通过 Activator.CreateInstance(...) 初始化 COM+ 组件“TestFirst”,该组件通过 COM+ 应用程序代理进行路由,然后调用实例上的方法。

远程服务器:

TestFirst ->来自客户端的方法调用通过使用“new”关键字初始化 COM+ 组件“TestSecond”,然后调用实例上的方法。

TestSecond ->调用私有程序集中包含的类的方法; “TestThird

问题:

为了成功调用TestSecond,似乎我必须将程序集安装到GAC。否则,我会收到此错误;

无法加载类型“TestSecond.TestSecond、TestSecond、Version=1.0.0.0、Culture=neutral、PublicKeyToken=...”。

好的,所以我将 TestSecond.dll 添加到 GAC,然后...

无法加载文件或程序集“TestThird,Version=1.0.0.0,Culture=neutral,PublicKeyToken=...”或其依赖项之一。系统找不到指定的文件。

这里显而易见的答案是将 TestThird 添加到 GAC 中,这确实有效,但我不想走这条路。这只是一个概念证明,遵循此结构的实际项目有许多私有程序集引用,我想避免将它们全部添加到 GAC 中,以便这些 COM+ 组件可以看到它们。

还有其他选择吗?是否有某种方法可以将工作目录与 GAC 注册的程序集关联起来?

注意:这个问题与我在本周提出的另一个问题无关,但我特别关注 GAC 安装的程序集的依赖关系解析。

COM+ 组件调用其他 COM+ 组件 - “无法加载类型”

Background Info:

I have two COM+ components on a remote server, based on .NET assemblies, one of which calls the other, which in turn calls a private assembly.

My chain of calls looks like this;

Client Machine:

Test Harness -> Initialises COM+ component "TestFirst" through Activator.CreateInstance(...), which routes via COM+ application proxy, then calls a method on the instance.

Remote Server:

TestFirst -> Method call from client initialises a COM+ component "TestSecond" through "new" keyword use, then calls a method on the instance.

TestSecond -> Calls a method on a class contained in a private assembly; "TestThird"

The Problem:

In order for the TestSecond to be called successfully, it seems that I have to install the assembly to the GAC. Otherwise, I get this error;

Cannot load type 'TestSecond.TestSecond, TestSecond, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...'.

OK, so I add TestSecond.dll to the GAC and then...

Could not load file or assembly 'TestThird, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...' or one of its dependencies. The system cannot find the file specified.

The obvious answer here is to add TestThird to the GAC too, which does work, but I would prefer not to go down this road. This is just a proof of concept, and the actual project which follows this structure has many private assembly references and I would like to avoid adding them all to the GAC just so these COM+ components can see them.

Is there any alternative? Is there perhaps some way of associating a working directory with a GAC registered assembly?

Note: This question is tangentially related to another question I asked during the week, but I'm specifically focusing on the dependency resolving of GAC installed assemblies.

COM+ component calling other COM+ components - "Cannot load type"

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

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

发布评论

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

评论(1

眉目亦如画i 2024-10-08 05:20:47

您可以使程序集从您选择的任何安装路径加载其依赖程序集:

http://www.chilkatsoft .com/p/p_502.asp

(与该公司没有关联,他们的示例似乎相对清晰。)

You can make your assemblies load their dependent assemblies from whatever install path you choose:

http://www.chilkatsoft.com/p/p_502.asp

(No association with that company, their example just seemed relatively clear.)

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