Loading Assemblies

G

Guest

Hello all,

When dynamically loading classes through reflection using Assembly.LoadFrom
I have the following questions:

1) Once you load an assembly it doesn't appear you can unload it. If you
try to load an assembly multiple times does this cause any type of memory
issues?

2) If you load an assembly and later you try to load a newer version of the
same assembly, does .NET know it's the same assembly and if so, what happens?

3) Before you execute Assembly.LoadFrom should you check to see if the
assembly is already loaded to avoid loading it again and if so how?

Thanks in advance,
John F
 
A

Andreas Mueller

John said:
Hello all,

When dynamically loading classes through reflection using Assembly.LoadFrom
I have the following questions:

1) Once you load an assembly it doesn't appear you can unload it. If you
try to load an assembly multiple times does this cause any type of memory
issues?

2) If you load an assembly and later you try to load a newer version of the
same assembly, does .NET know it's the same assembly and if so, what happens?

3) Before you execute Assembly.LoadFrom should you check to see if the
assembly is already loaded to avoid loading it again and if so how?

Thanks in advance,
John F

see http://tinyurl.com/2r7g4
1) Almost correct. You can only unload appdomains. What you can do is to
create a new AppDomain and load you assembly into it. However, you also
have to make sure to create your object inside the new domain using
AppDomain.CreateInstanceAndUnwrap(..).
I haven't had any issues calling LoadFrom multiple times.

2)If you have a string named assembly and the version is higher it will
get loaded.

3) see 1)

HTH,
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top