|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Loading assemblies dynamically using my own ResolveEventHandlerown custom ResolveEventHandler that their Modules do not get returned when I invoke Process.GetCurrentProcess().Modules Here is some pseudo code to show what I'm talking about: public class Foo { public Foo () { SomeClassInDynamicallyLoadedAssembly myObj = new SomeClassInDynamicallyLoadedAssembly(); foreach (ProcessModule module in Process.GetCurrentProcess().Modules) { Trace.WriteLine("module: "+module.FileName); } } public static int main (string [] args) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Foo foo = new Foo(); } private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { // get the bytes for this assembly - wherever it might be (could be an embedded resource) return Assembly.Load(bytes); } } I can see that the assembly is getting loaded without issue since I can use the classes that are stored in it. But that module doesn't appear in the current processes list of modules. any suggestions? Thanks, Novice Hmm... I guess I'm not too likely to get an answer to this question -
doesn't seem like there are many resources on this stuff. One thing I've been experimenting with is that I can find the dynamically loaded assemblies in both of the following collections: AppDomain.CurrentDomain.GetAssemblies() Assembly.GetExecutingAssembly().GetReferencedAssemblies() Oddly enough the referenced assemblies seems to only include the dll's that are embedded or contained in the GAC... not sure if that is entirely accurate, but that seems to be what it is. Whereas the GetAssemblies method invocation will return all of those assemblies, in addition to any assemblies that you might have added in your references. Strange... Novice illegal.pr***@gmail.com wrote: Show quote > Hey all, so I've noticed that when I load assemblies dynamically in my > own custom ResolveEventHandler that their Modules do not get returned > when I invoke > Process.GetCurrentProcess().Modules > > Here is some pseudo code to show what I'm talking about: > > public class Foo > { > > public Foo () > { > SomeClassInDynamicallyLoadedAssembly myObj = new > SomeClassInDynamicallyLoadedAssembly(); > foreach (ProcessModule module in > Process.GetCurrentProcess().Modules) > { > Trace.WriteLine("module: "+module.FileName); > } > } > > public static int main (string [] args) > { > AppDomain.CurrentDomain.AssemblyResolve += new > ResolveEventHandler(CurrentDomain_AssemblyResolve); > Foo foo = new Foo(); > } > > private static Assembly CurrentDomain_AssemblyResolve(object sender, > ResolveEventArgs args) > { > // get the bytes for this assembly - wherever it might be (could be > an embedded resource) > return Assembly.Load(bytes); > } > } > > I can see that the assembly is getting loaded without issue since I can > use the classes that are stored in it. But that module doesn't appear > in the current processes list of modules. > > any suggestions? > > Thanks, > Novice |
|||||||||||||||||||||||