调用的Assembly.Load多次的副作用 [英] Side effects of calling Assembly.Load multiple times

查看:283
本文介绍了调用的Assembly.Load多次的副作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个叫的Assembly.Load 多次不会造成任何副作用?

例如。

 的for(int i = 0; I&n种;我++)
{
   的Assembly.Load(assemblyStrongName);
   // .......
}
 

此加载程序集一次,不是吗?我已经与 AppDomain.CurrentDomain.GetAssemblies()检查之前和之后,似乎它的加载一次(因为它应该),但它有副作用吗?

在一个长期运行的服务器应用程序(运行数月/年,没有重新启动)完成了上述原因的任何问题?

解决方案
  

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

是的。该组件被加载到当前的AppDomain,并且只能使用一次加载到AppDomain中。调用此多次刚刚返回现有组件。

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?

解决方案

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.

这篇关于调用的Assembly.Load多次的副作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆