用第一个就会报"未能从程序集 WindowsApplication1, Version=1.0.859.19452, Culture=neutral, PublicKeyToken=null 中加载类型 System.Windows.Forms.Button。"
你不报错当然就是null了.你可以自己定义一个类型再试一下.

解决方案 »

  1.   

    自己定义的类可以,就连System.Int32等都可以,但是System.Windows.Forms.Button就不可以,不过我恰巧要用System.Windows.Forms.Button。
      

  2.   

    参数应该是full qualified typename。用这个:
    Type.GetType("System.Windows.Forms.Button, System.Windows.Forms");
    true加不加都没关系。
      

  3.   

    To:qqchen79(知秋一叶)还是出错
    未处理的“System.IO.FileNotFoundException”类型的异常出现在 WindowsApplication3.exe 中其他信息:找不到文件或程序集名称“System.Windows.Forms”,或找不到它的一个依赖项。
      

  4.   

    你用typeof吧,
    Type t=typeof(System.Windows.Forms.Button);
    ...
      

  5.   

    感谢您使用微软产品。可以通过如下两种方式来实现您的目的:
    (1)在VC#中使用typeof:
    Type myTypeBindingFlags = typeof(System.Windows.Forms.Button);
    (2)第二中方法是:
    using System.Reflection;
    ……
    Assembly assembly=null;
    assembly = Assembly.LoadFrom("C:\\WINNT\\Microsoft.NET\\Framework\\v1.0.3705\\System.Windows.Forms.dll");
    Type tt = assembly.GetType("System.Windows.Forms.Button", true);
    希望这些信息对你有帮助。 — 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
    为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
      

  6.   

    sorry, 看来GAC里面的assembly只能使用全名来引用了:
    string aname = "System.Windows.Forms.Button, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
    Type t = Type.GetType(aname, true);