Type.GetType("namespace.a.b.ClassName") 返回 null [英] Type.GetType("namespace.a.b.ClassName") returns null
本文介绍了Type.GetType("namespace.a.b.ClassName") 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码:
Type.GetType("namespace.a.b.ClassName")
返回null
.
我有使用:
using namespace.a.b;
更新:
该类型存在,它在不同的类库中,我需要通过字符串名称获取它.
The type exists, it's in a different class library, and i need to get it by string name.
推荐答案
Type.GetType("namespace.qualified.TypeName")
仅在 mscorlib.dll 或当前正在执行程序集.
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:
Type.GetType("namespace.qualified.TypeName, Assembly.Name")
这篇关于Type.GetType("namespace.a.b.ClassName") 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文