This is a common issue with Type.GetType to which you need to pass in
the "fully qualified name" by which I do not mean the namespace
qualified name, I mean the AssemblyQualifiedName.
Try this :
--
string name = "System.Windows.Forms.Button, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
Type t = Type.GetType(name);
if (t = null)
{
Console.WriteLine("I failed.");
}
else
{
Console.WriteLine("Mommy, I found a Button !! ");
}
For this reason (you need to know the entire assembly qualified name),
using the "typeof" keyword in C# proves very convenient.
On Feb 3, 10:31 pm, Ramon Lopes <[email protected]> wrote:
> Hello everybody,
>
> I've been facing some problems using Reflection.
> I have a class name, for example
>
> string name = "System.Windows.Forms.Button";
>
> so, I would like to get a Type object of the name variable refers to.
>
> The method Type.GetType() accepts a string argument, but it doesn't work,
> that is Type.GetType("System.Windows.Forms.Button") always returns Null.
>
> Could someone help me?
>
> --
> Ramon Pereira Lopes