加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – Type.GetType不工作

发布时间:2020-12-15 18:22:29 所属栏目:百科 来源:网络整理
导读:参见英文答案 Type.GetType(“namespace.a.b.ClassName”) returns null16个 我刚刚注意到函数中的一个错误: Type.GetType("System.Uri"); 返回值为null,而以下函数运行良好… Type.GetType("System.string");Type.GetType("System.bool");Type.GetType("Sy
参见英文答案 > Type.GetType(“namespace.a.b.ClassName”) returns null16个
我刚刚注意到函数中的一个错误:
Type.GetType("System.Uri");

返回值为null,而以下函数运行良好…

Type.GetType("System.string");
Type.GetType("System.bool");
Type.GetType("System.DateTime");

任何人都知道,为什么返回的Type为null?

编辑:删除Uri双重进入…

解决方法

Type.GetType(“System.Uri”)返回null的原因是该类型位于system.dll而不是mscorlib.dll.您必须使用上面提到的程序集限定名称.

来自MSDN:

typeName
Type: System.String

The assembly-qualified name of the type to get. See AssemblyQualifiedName. If the type is in the currently executing assembly or in Mscorlib.dll,it is sufficient to supply the type name qualified by its namespace.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读