M
Michi Henning
Hi,
I'm stuck on a reflection problem. Here is an outline
of what's happening
// In A.exe:
class A
{
// ...
System.Type t = System.Type.GetType("A"); // Works fine
}
// In assembly B, used by A.exe:
// ...
System.Type t = System.Type.GetType("A"); // Returns null
The problem is that GetType() finds a type only if it is
in the calling object's assembly or in mscorlib.dll. But, in
this case, the type is defined in A.exe but has to be looked
up in assembly B.
I can't find a way to make this work. I know that I can call
ProcessModuleCollection mc = Process.GetCurrentProcess().Modules;
This gets me all the modules that are loaded by the
current process. However, I can't work out a way to get the list
of assemblies that are loaded by the current process, so I could
search them one by one for a definition of the type I need.
In Java, what I'm trying to do works just fine, even if the type
I'm looking for is defined in a different jar file.
Is there any way to do this in C#?
Thanks,
Michi.
I'm stuck on a reflection problem. Here is an outline
of what's happening
// In A.exe:
class A
{
// ...
System.Type t = System.Type.GetType("A"); // Works fine
}
// In assembly B, used by A.exe:
// ...
System.Type t = System.Type.GetType("A"); // Returns null
The problem is that GetType() finds a type only if it is
in the calling object's assembly or in mscorlib.dll. But, in
this case, the type is defined in A.exe but has to be looked
up in assembly B.
I can't find a way to make this work. I know that I can call
ProcessModuleCollection mc = Process.GetCurrentProcess().Modules;
This gets me all the modules that are loaded by the
current process. However, I can't work out a way to get the list
of assemblies that are loaded by the current process, so I could
search them one by one for a definition of the type I need.
In Java, what I'm trying to do works just fine, even if the type
I'm looking for is defined in a different jar file.
Is there any way to do this in C#?
Thanks,
Michi.