Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / November 2006

Tip: Looking for answers? Try searching our database.

Assemblies and acope

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ron M. Newman - 29 Nov 2006 20:43 GMT
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
Mattias Sjögren - 29 Nov 2006 21:32 GMT
>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

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Ron M. Newman - 29 Nov 2006 21:37 GMT
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

>>1) What happens to the actual assembly.dll when the method goes out of
>>scope? will it close?
[quoted text clipped - 11 lines]
>
> Mattias
Jon Shemitz - 29 Nov 2006 21:59 GMT

> 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.

Signature

.NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net
What you need to know.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.