Assemblies and acope

  • Thread starter Thread starter Ron M. Newman
  • Start date Start date
R

Ron M. Newman

Hi,

If I declare an assembly within a method and call ".Load" on it...

public void foo()
{
Assembly asm = Assembly.Load("myassembly.dll");
}

1) What happens to the actual assembly.dll when the method goes out of
scope? will it close?
2) what would happen to types I instantiate that are in that assembly? will
they "survive" and be healthy? (providing of course they're still in scope)

thanks,
Ron
 
1) What happens to the actual assembly.dll when the method goes out of
scope? will it close?

No. The only time an assembly is "closed" or unloaded is when the
appdomain is unloaded.

2) what would happen to types I instantiate that are in that assembly? will
they "survive" and be healthy? (providing of course they're still in scope)

The objects you create will stay in memory as long as they are
referenced.


Mattias
 
So: just to see if I got it right... the assembly is loaded in the method,
referenced there by a temporary reference, and when that reference goes out
of scope nothing really happens as it's also referenced by the main app
domain which holds it. It can be easily referenced back using the app domain
API's

Ron
 
Ron M. Newman said:
So: just to see if I got it right... the assembly is loaded in the method,
referenced there by a temporary reference, and when that reference goes out
of scope nothing really happens as it's also referenced by the main app
domain which holds it. It can be easily referenced back using the app domain
API's

Yes.
 

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

Back
Top