Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Side effects of calling Assembly.Load multiple times

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?

like image 763
JohnDoDo Avatar asked Feb 16 '12 17:02

JohnDoDo


1 Answers

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.

like image 194
Reed Copsey Avatar answered Oct 22 '22 03:10

Reed Copsey