多次调用 Assembly.Load 的副作用

发布于 2025-01-06 20:56:54 字数 343 浏览 5 评论 0原文

如果多次调用 Assembly.Load 是否会产生任何副作用?

例如,

for (int i = 0; i < N; i++) 
{
   Assembly.Load(assemblyStrongName);
   // .......
}

这会加载一次程序集,不是吗?我前后检查过 AppDomain.CurrentDomain.GetAssemblies() ,似乎它加载了一次(正如它应该的那样),但它有副作用吗?

在长时间运行的服务器应用程序(运行数月/数年而不重新启动)中,上述情况是否会导致任何问题?

If one calls Assembly.Load multiple times does it cause any side effects?

e.g.

for (int i = 0; i < N; i++) 
{
   Assembly.Load(assemblyStrongName);
   // .......
}

This loads the assembly one time doesn't it? I've checked with AppDomain.CurrentDomain.GetAssemblies() before and after and it seems it's loaded one time (as it should) but does it have side effects?

In a long running server application (runs for months/years with no restart) does the above cause any issues?

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

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

发布评论

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

评论(1

初心未许 2025-01-13 20:56:54

这会加载一次程序集,不是吗?

是的。该程序集被加载到当前的 AppDomain 中,并且只会在该 AppDomain 中加载一次。多次调用只会返回现有的程序集。

This loads the assembly one time doesn't it?

Yes. The assembly gets loaded into the current AppDomain, and will only be loaded once into that AppDomain. Calling this multiple times just returns the existing assembly.

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