Omu Omu - 3 months ago 18
C# Question

Type.GetType("namespace.a.b.ClassName") returns null

This code:

Type.GetType("namespace.a.b.ClassName")


returns
null
.

and I have in the usings:

using namespace.a.b;


Update:

The type exists, it's in a different class library, and i need to get it by string name.

Answer

Type.GetType("namespace.qualified.TypeName") only works when the type is found in either mscorlib.dll or the currently executing assembly.

If neither of those things are true, you'll need an assembly-qualified name.

Comments