多个应用程序域调用同一个非托管 dll

发布于 2024-08-26 03:39:09 字数 232 浏览 2 评论 0原文

我们的 .NET 3.5 C# 应用程序创建多个应用程序域。每个应用程序域加载相同的非托管第 3 方 dll。该 dll 在初始化时读取配置文件。如果配置在运行时发生变化,则必须卸载并重新加载 dll。该 dll 不在我们正确重写的范围内。

每个应用程序域是否都可以访问此非托管 dll 的单独副本,或者 Windows 是否保留该 dll 的一份副本并维护使用计数?如果是后者,我们如何让非托管 dll 的每个实例反映其独特的配置?

Our .NET 3.5 C# application creates multiple appdomains. Each appdomain loads the same unmanaged 3rd party dll. This dll reads a configuration file upon initialization. If the configuration changes during runtime, the dll must be unloaded and loaded again. This dll is not in our scope to rewrite correctly.

Does each appdomain have access to a separtate copy of this unmanaged dll, or does Windows keep one copy of the dll and maintain a usage count? If the latter is is the case, how do we get each instance of the unmanaged dll to reflect its unique configuration?

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

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

发布评论

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

评论(1

喵星人汪星人 2024-09-02 03:39:09

我认为操作系统每个进程仅加载非托管 dll 一次,因此每个应用程序域都将具有相同的加载实例。要卸载 dll,请使用 FreeLibrary 函数。但是,由于多个应用程序域可能已加载该 dll,因此无法保证来自一个应用程序域的 FreeLibrary 实际上会释放/卸载该 dll。

正如 BillW 所说,这对我来说似乎也是一场设计噩梦!

I think unmanaged dlls are loaded only once per process by the OS, so every app-domain will have the same loaded instance. To unload a dll, use the FreeLibrary function. However, since multiple app-domains are likely to have loaded the dll, there is no guarantee that FreeLibrary from one app-domain will actually free/unload the dll.

As BillW says, this seems like a design nightmare to me too!

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