RE: Dynamic Load Assembly
From: BrianS (BrianS_at_discussions.microsoft.com)
Date: 01/06/05
- Previous message: Joakim Karlsson: "Re: Scripting Engine (somewhat advanced)"
- In reply to: BrianS: "Dynamic Load Assembly"
- Next in thread: David Levine: "Re: Dynamic Load Assembly"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 6 Jan 2005 12:43:04 -0800
In otherwords,
AppDomain.CurrentDomain.GetAssemblies
returns an unloaded/unreferenced assembly.why?
"BrianS" wrote:
> I have Web Service (A) that dynamically loads a private assembly (B). I do
> NOT reference B in A. ( I do reference A in B, but that should not matter?).
> Both these Assemblies reside in the A's /Bin.
>
> I dynamically load B and Invoke a Method:
>
> 'Create evidence for the new appdomain.
> Dim adevidence As System.Security.Policy.Evidence =
> AppDomain.CurrentDomain.Evidence
>
> ' Create the new application domain.
> Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain",
> adevidence,AppDomain.CurrentDomain.SetupInformation)
> Dim myAssembly As [Assembly] = domain.Load(strAssemblyName)
> Dim sysType As Type = myAssembly.GetType(strClassName)
>
> obj = Activator.CreateInstance(sysType, New Object())
>
> ' Invoke the method
> Dim intBindings As Integer = BindingFlags.DeclaredOnly Or
> BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Instance Or
> BindingFlags.InvokeMethod
> returnObj= obj.GetType.InvokeMember(strMethod, intBindings, Nothing, obj,
> New Object())
>
> ' Unload the application domain.
> AppDomain.Unload(domain)
>
> It was my understanding to load the assembly into a new AppDomain so I can
> explicity Unload the AppDomain to free resources.
>
> However, when I excecute my Web Service (A) and I am on the Service Page
> (where all methods are listed) I see that B has already been loaded in the
> aspnet_wp.exe process using Process Explorer?
>
> Why would this be? Is it because, using the Load context, since assemblies
> reside in the same path, .Net automactically loads them at startup?
>
> I tried commenting out the code above, but it still loads the assembly at
> startup.
>
>
- Previous message: Joakim Karlsson: "Re: Scripting Engine (somewhat advanced)"
- In reply to: BrianS: "Dynamic Load Assembly"
- Next in thread: David Levine: "Re: Dynamic Load Assembly"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|