Quantcast
Channel: how to unload Assembly?
Viewing all articles
Browse latest Browse all 5

how to unload Assembly?

$
0
0

Hi,

first of all: When you use the web to enter your text, you see a symbol like a window with </> in it - this can be used to enter code to the forum. Everething else results in a unreadable code.

Next is: You know the MSDn Library? In there you find all information required. You already found the correct class: AppDomain. So just have a closer look at it and you will find the Methods CreateDomain and Unload in them - together with some simple examples inside the documentation.

http://msdn.microsoft.com/en-us/library/system.appdomain.aspx
http://msdn.microsoft.com/en-us/library/47e8e141.aspx
http://msdn.microsoft.com/en-us/library/system.appdomain.unload.aspx

So a simple example could be:

Imports SystemImports System.ReflectionImports System.Security.Policy 'for evidence objectClass ADUnloadPublicSharedSub Main()'Create evidence for the new appdomain.Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence' Create the new application domain.Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence)

   Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName))
   Console.WriteLine(("child domain: " + domain.FriendlyName))' Unload the application domain.
   AppDomain.Unload(domain)Try
     Console.WriteLine()' Note that the following statement creates an exception because the domain no longer exists.
     Console.WriteLine(("child domain: " + domain.FriendlyName))Catch e As AppDomainUnloadedException
     Console.WriteLine("The appdomain MyDomain does not exist.")EndTryEndSub'Main EndClass'ADUnload

And for loading the assembly into the AppDomain: Use the Load method.

With kind regards,

Konrad 


Viewing all articles
Browse latest Browse all 5

Trending Articles