E
Erland
Hi,
I've been trying to load a type and and get all of the methods within
that type. I finally made it happen by using typeof, but im really
stumped how could one implement the same with Type.GetType(). I have
read the documentation and it says that this looks currently executing
assembly and mscorlib.dll. I have couple of questions in this regard i
hope someone will take some time off to answer them and i will
appreciate that.
1-I finally succeeded by using the following code
Type t=typeof(System.Windows.Forms.Button);
MethodInfo[] methods=t.GetMethods();
foreach(MethodInfo in nextmethod in methods)
{
Console.WriteLine(nextmethod.Name)
}
NOW why i can't do same as above using Type.GetType() ? If i can
acheive what i am trying to do above by using Type.GetType() then
please let me know how?
2--By using Google , on various places i have seen people advising that
one must use fully qualified assembly name. How could i get a fully
qualified name by using Type.GetType( ) e.g. if i use following i get
an error
Type t=Type.GetType("System.Windows.Forms.Button");
Console.WriteLine(t.AssemblyQualifiedName);
3-I tried this way but failed , i just would like to know why it
failed. First i loaded an Assembly using Assembly.Load() then i tried
to get the type using Assemblyinstance.GetType("abc"), allright i can't
explain it here just see the code below
Assembly asm=Assembly.Load("System.Windows.Forms");
Type asm=asm.GetType("System.Windows.Forms.Button");
MethodInfo[] methods=asm.GetMethods();
foreach(MethodInfo in nextmethod in methods)
{
Console.WriteLine(nextmethod.Name)
}
why the above code *doesn't* show me the methods of type
System.windows.forms.button , i means what is wrong with it ?
I will really appreciate any help.
Thanks in advance.
-Erland
I've been trying to load a type and and get all of the methods within
that type. I finally made it happen by using typeof, but im really
stumped how could one implement the same with Type.GetType(). I have
read the documentation and it says that this looks currently executing
assembly and mscorlib.dll. I have couple of questions in this regard i
hope someone will take some time off to answer them and i will
appreciate that.
1-I finally succeeded by using the following code
Type t=typeof(System.Windows.Forms.Button);
MethodInfo[] methods=t.GetMethods();
foreach(MethodInfo in nextmethod in methods)
{
Console.WriteLine(nextmethod.Name)
}
NOW why i can't do same as above using Type.GetType() ? If i can
acheive what i am trying to do above by using Type.GetType() then
please let me know how?
2--By using Google , on various places i have seen people advising that
one must use fully qualified assembly name. How could i get a fully
qualified name by using Type.GetType( ) e.g. if i use following i get
an error
Type t=Type.GetType("System.Windows.Forms.Button");
Console.WriteLine(t.AssemblyQualifiedName);
3-I tried this way but failed , i just would like to know why it
failed. First i loaded an Assembly using Assembly.Load() then i tried
to get the type using Assemblyinstance.GetType("abc"), allright i can't
explain it here just see the code below
Assembly asm=Assembly.Load("System.Windows.Forms");
Type asm=asm.GetType("System.Windows.Forms.Button");
MethodInfo[] methods=asm.GetMethods();
foreach(MethodInfo in nextmethod in methods)
{
Console.WriteLine(nextmethod.Name)
}
why the above code *doesn't* show me the methods of type
System.windows.forms.button , i means what is wrong with it ?
I will really appreciate any help.
Thanks in advance.
-Erland