getting a type from the class name

  • Thread starter Thread starter Andy Fish
  • Start date Start date
A

Andy Fish

Hi,

If I want to get a reference to a type given its name, it seems it either
has to be in the same assembly, or I have to know the assembly name. Is
there no way to simply look at all running assemblies for a type of that
name?

Basically I'm looking for the equivalent of Java's Class.ForName() and I
don't understand why there doesn't seem to be one.

TIA

Andy
 
Andy Fish said:
If I want to get a reference to a type given its name, it seems it either
has to be in the same assembly, or I have to know the assembly name. Is
there no way to simply look at all running assemblies for a type of that
name?

Basically I'm looking for the equivalent of Java's Class.ForName() and I
don't understand why there doesn't seem to be one.

Well, there isn't quite the same ClassLoader idea as in Java. An
AppDomain is similar, but not quite the same.

Anyway, you can ask an Assembly for all its referenced assemblies, and
then load each of those which hasn't already been loaded, and ask each
in turn for the type you're after.
 
Back
Top