C#.NET - Type.GetType(" System.Windows.Forms.Form中")返回null [英] C#.NET - Type.GetType("System.Windows.Forms.Form") returns null

查看:288
本文介绍了C#.NET - Type.GetType(" System.Windows.Forms.Form中")返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序的code的片段(它引用System.Windows.Forms的的),它试图解决的类型信息的表格像这样的类:

I have a snippet of code in my application (which references System.Windows.Forms) which attempts to resolve type information for a Form class like so:

Type tForm = Type.GetType("System.Windows.Forms.Form");
dynamic instance = Activator.CreateInstance(tForm);

Activator.CreateInstance 失败,因为 TForm的为空。

but Activator.CreateInstance fails because tForm is null.

我要如何解决这个问题?

How do I solve this?

编辑:类型必须是可解析在运行时

推荐答案

您需要使用的类型的程序集限定名称

You need to use assembly-qualified name of the type

Type tForm = Type.GetType("System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

这篇关于C#.NET - Type.GetType(" System.Windows.Forms.Form中")返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆