.NET 运行时如何定位非强命名的?大会?

发布于 2024-08-21 17:15:09 字数 609 浏览 10 评论 0原文

我们有不同版本的非强命名程序集,并且 app.exe.config 中没有绑定重定向/探测它们的路径。例如,MyDll (1.0.0.0_null_neutral) 和 MyDll (2.0.0.0_null_neutral)。相对于app.exe,这些程序集存储在LAC\MyDll_1.0.0.0_null_neutral和LAC\MyDll_2.0.0.0_null_neutral中。

我的理解是,由于 MyDll 程序集没有强命名,.NET 运行时不区分不同版本的 MyDll。因此,如果 MyDll 1.0.0.0 已加载到内存中,并且执行了一些针对 MyDll 2.0.0.0 构建的代码,则 .NET 运行时将不会加载 MyDll 2.0.0.0。

但是,当我使用 VS2008 附加到该进程并查看模块窗口时,我注意到 MyDll 1.0.0.0 和 MyDll 2.0.0.0 都是从 LAC 文件夹加载的。

我的理解似乎在某个地方存在差距。有人可以指出吗?

编辑: 感谢到目前为止的回复。是的,我跳过了那一点。可执行文件侦听 AssemblyResolve 事件,并通过在 LAC 中查找来处理该事件。

我很确定我之前看过一些 MSDN 文档,说除非程序集具有强名称,否则版本将被忽略。我看看能不能挖出来

We have different versions of non strong-named assemblies, and no binding redirects/probing paths to them in app.exe.config. For example, MyDll (1.0.0.0_null_neutral) and MyDll (2.0.0.0_null_neutral). Relative to app.exe, these assemblies are stored in LAC\MyDll_1.0.0.0_null_neutral and LAC\MyDll_2.0.0.0_null_neutral.

My understanding is that because the MyDll assemblies are not strong-named, the .NET runtime doesn't differentiate between different versions of MyDll. Therefore, if MyDll 1.0.0.0 were already loaded into memory and some code that was built against MyDll 2.0.0.0 was executed, the .NET runtime would not load MyDll 2.0.0.0.

However, when I attached to the process with VS2008 and viewed the modules window, I noticed that both MyDll 1.0.0.0 and MyDll 2.0.0.0 were loaded from the LAC folder.

There seems to be a gap in my understanding somewhere. Can someone please point it out?

EDIT:
Thanks for the responses so far. Yes, I skipped over that bit. The executable listens to the AssemblyResolve event, and handles it by looking in the LAC.

I was pretty sure I saw some MSDN documentation before that said versions are ignored unless an assembly is strong-named. I'll see if I can dig it up.

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

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

发布评论

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

评论(1

暖伴 2024-08-28 17:15:09

http://msdn.microsoft.com/en-us/library/yx7xezcf。 aspx

第 2 步是检查它是否已加载,这是特定于版本的,即使项目没有强命名。

步骤 4 尝试通过探测加载程序集,这不是特定于版本的。

我感到困惑的是,如果您的配置文件中没有任何信息,那么它首先是如何找到 DLL 的呢?我认为我的理解也存在差距:-)。

http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

Step 2 is checking to see if it's been loaded, and that is version specific, even with items that aren't strongly named.

Step 4 is trying to load the assembly through probing, and this is not version specific.

What I'm confused about is if you don't have any information in your config file, how is it finding the DLL in the first place? I think there's a gap in my understanding as well :-).

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