为什么引用的程序集被锁定?

发布于 2024-09-13 21:28:47 字数 132 浏览 6 评论 0原文

我有 2 个组件。 Assembly2 被 Assembly1 引用。 为什么 Assembly2 被锁定?

我认为整个程序集是由 JIT 编译器加载到 RAM 中的,不是吗?

当调用引用的程序集时,该机制如何工作?

I have 2 assemblies. Assembly2 is referenced by Assembly1.
Why is Assembly2 locked?

I thought the whole assembly is loaded into the RAM by the JIT-Compiler, isn't it?

How does the machinism work when a referenced assembly is called?

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

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

发布评论

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

评论(2

爱情眠于流年 2024-09-20 21:28:47

(是的,这个问题本来可以更好,但是......)

引用的程序集被加载到进程中并因此被锁定。您可以通过卷影复制来解决这个问题,或者只是确保在尝试修改程序集之前关闭使用程序集的每个进程。

(yes, the question could have been better, still...)

Referenced assemblies are loaded into the process and are thus locked. You can get around this with shadow copying, or just make sure you close every process that uses your assemblies before you attempt to modify them.

日记撕了你也走了 2024-09-20 21:28:47

我在编写要在 VB6 应用程序中使用的 .NET 组件时遇到了一种情况,当 VB6 编辑器打开时,我无法部署重新编译的 .NET 程序集。这真的让我很沮丧,因为我希望能够快速进行更改,然后将更改显示在我的 VB6 编辑器中。我收到一条错误消息,表明程序集已被另一个进程或线程锁定。

后来我意识到这很有意义。如果引用应用程序(在我的例子中是 VB6 IDE)每次使用该库时都相信该库是相同的,那么当应用程序位于内存中时 dll 发生更改,就会遇到严重的问题。

就我而言,关闭 VB6 IDE,更新 dll,然后重新打开 VB6 IDE 效果很好。这对我的工作流程来说是一个小小的障碍,但一旦我意识到为什么会发生这种情况,我就克服了它。

I ran into a situation when writing a .NET componenet to be consumed in a VB6 app where I couldn't deploy my recompiled .NET assembly while the VB6 editor was open. This really frustrated me because I wanted to be able to just make a quick change and then have the change show up in my VB6 editor. I was getting an error message that the assembly was locked by another process or thread.

I later realized that this made a lot of sense. If the referencing application (in my case, the VB6 IDE) is trusting that library to be the same each time it goes to consume it, it's going to run into serious problems if the dll changes while the application is in memory.

In my case, closing the VB6 IDE, updating the dll, and reopening the VB6 IDE worked just fine. It was a little bit of a hindrance in my workflow, but once I realized why it was happening, I got over it.

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