DLL Hell:旧的 .dll 文件分成两部分?

发布于 2025-01-08 12:56:22 字数 907 浏览 1 评论 0原文

我遇到一个问题,其中项目需要使用的组件被配置为使用旧的 DLL。其他组件使用此 DLL 的较新版本,并且 BindingRedirect 似乎可以解决大部分此类问题。

这是一个有趣的问题,我不确定如何解决(对使用抽象名称表示歉意): 组件X尝试在DLL A中查找类型Y,因为在旧版本中Y驻留在A中。但是,在更高版本中A已经被分成两个 DLL 文件,AB(其中包含 A 中发现的内容的一个特殊分支)。 Y 型已从 A 移至 B,但许多其他重要组件仍驻留在 A 中。 有没有办法进行绑定,以便 X 在 B 中查找这些类而不是 A,或者有其他方法来解决这个问题? 我无法访问任何源代码,但确实有旧的 A .dll,尽管我总是想同时使用新的 A .dll。

我尝试过使用 codeBase 属性链接到旧的 A,但效果很差,还有 QualifyAssembly,它似乎也没有达到我正在寻找的效果。

编辑:作为解决方法,我创建了一个名为 LegacyDlls 的单独文件夹,该文件夹与我的 bin 文件分开(这部分非常重要),并将旧版本的程序集 A 放在其中。然后我使用了如下代码库标签:

<dependentAssembly>  
            <assemblyIdentity name="A" culture="neutral" publicKeyToken="AkeyGoesHere" />

            <codeBase version="2.1.0.0" href="LegacyDlls\A.dll" />
        </dependentAssembly>

并且我不再收到 TypeLoad 异常,所以我认为这意味着进步!

I have a problem wherein a component I need to use for a project is configured to use an old DLL. Other components use the newer version of this DLL, and bindingRedirect seems to take care of most of these issues.

Here is the interesting issue that I am unsure how to solve (apologies for using abstarct names):
Component X tries to look for type Y in DLL A, because in the older version Y resided in A. However, in later versions A has been split into two DLL files, A and B (which contains a special branch of the things found in A). Type Y has been moved out of A and into B, but a lot of other important components are still residing in A.
Is there a way to make a binding so that X looks in B for these classes instead of A, or another way to solve this?
I lack access to any source code, but do have the old A .dll, although I would always want to use the new A .dll simultaneously.

I have tried using the codeBase property to link to old A, which went poorly, and QualifyAssembly, which also does not seem to do what I was searching for.

EDIT: As a workaround, I created a separate folder called LegacyDlls whuich is separate from my bin files (this part is very important) and placed the old version of Assembly A in there. Then I used a codebase tag like so:

<dependentAssembly>  
            <assemblyIdentity name="A" culture="neutral" publicKeyToken="AkeyGoesHere" />

            <codeBase version="2.1.0.0" href="LegacyDlls\A.dll" />
        </dependentAssembly>

And I no longer get a TypeLoad exception, so I think this means progress!

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

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

发布评论

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

评论(1

花间憩 2025-01-15 12:56:22

听起来你把自己逼到了墙角。

有一些方法可以通过发出代码并在运行时将 B 中的方法添加到 A 中来实现此目的,但从长远来看,这会导致严重的维护问题,因此我不建议这样做。

要么等待组件获得在新 dll 上运行的新版本,要么在没有它的情况下工作。

Sounds like you painted yourself into a corner.

There are ways of doing this by emitting code and adding the methods from B into A at runtime, but that would lead to serious maintenance issues in the long term so I wouldn't suggest it.

Either wait for the component to get a new version running on the new dlls or work without it.

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