Enumerate loaded assemblies

  • Thread starter Thread starter =?ISO-8859-1?Q?Allan_Bo_J=F8rgensen?=
  • Start date Start date
?

=?ISO-8859-1?Q?Allan_Bo_J=F8rgensen?=

I've been coding standard .NET framework for almost two years now, but
I'm new to the compact framework. I'm currently porting from the
standard framework to the compact framework, and I've come across
something that I can not figure out how to do - enumerate the currently
loaded assemblies. In the standard framework, I'd use
System.AppDomain.CurrentDomain.GetAssemblies(), but this does not exist
in the compact framework. Lots of stuff is left out of the compact
framework, and I usually find my way around it or do without it, but
this functionality is crucial to application architecture. Is there some
way to get the same functionality?
 
What are you trying to accomplish?

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
I'm trying to enumerate all types that implement a certain set of
interfaces. We sort classes into certain categories depending on what
interface(s) they implement, and use this information to set up the
system. For instance, we have a system for logging program execution
information - this is done through any class that implements ILogWriter,
and the actual classname can just be a string in an INI-file. I can even
change it at runtime, and the system must then dynamically replace the
instance of the ILogWriter with an instance of another class. As the
system is suppose to be very dynamic, this class may be defined in an
already loaded assembly, or possibly an unloaded one. So I would like to
go over the assemblies already loaded to see what types are already
there and what ones aren't (and thus needs loading).

The reason for all this is so the core system can avoid having
references to all the necessary modules on the system, and the system
just loads and uses the modules that are necessary and present. It works
great on the full .NET framework, and we'd really like it work with
compact too.

- Allan
 
That means you're loading assemblies dynamically.
Why could not you keep references to loaded assemblies in a hash table or
array list and use it to enumerate classes you need?

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
I could - but some of them are loaded as part of the dependencies of
other, dynamically loaded, assemblies, and would therefore not appear on
the list. If I try to load those assemblies again directly, the type
system apparently stops working properly on the full .NET framework 1.0
(objects would not be created, even though they obviously should have
been. I traced that error to the loading of assemblies, that had already
been loaded as a dependency). I must admit I haven't tried that on the
CF yet. If that works, I guess I could just run through the assemblies
in the applications base directory and load them all to enumerate the
types. But like I wrote, that didn't work on the full .NET framework.

I was playing around with catching the AssemblyLoaded event on the
AppDomain object, but that's not available on the CF either.

- Allan
 
Back
Top