多次调用 Assembly.Load 的副作用
如果多次调用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。该程序集被加载到当前的 AppDomain 中,并且只会在该 AppDomain 中加载一次。多次调用只会返回现有的程序集。
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.