Type.GetType returns null

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am kind of curious on Type.GetType(string typeName) function. I have a
dll, myDll which contains a form, frmMyForm. It is refenced in another
application. When this application is trying to get the type of the form of
this dll, let's say
Type.GetType("mydll.frmMyForm") it returns null.
However, when I try with operator typeof(mydll.frmMyForm) it does return the
correct type.

Is there any explanation for this? Which methods offers better performance?

Thanks.
 
Try providing the assermbly name, where your form class is implemented,
like: Type.GetType("mydll.frmMyForm,MyFormAssembly")

"typeof" is faster; however "typeof" returns a System.Type reference to already
known type
(you have the assembly referenced already and you know that the type exists)

Type.GetType(string) is slower;however it is used for late binding - you
don't know actualy if type exists


Ruslan Trifonov
http://xman892.blogspot.com
 
Thank you :)

Ruslan Trifonov said:
Try providing the assermbly name, where your form class is implemented,
like: Type.GetType("mydll.frmMyForm,MyFormAssembly")

"typeof" is faster; however "typeof" returns a System.Type reference to already
known type
(you have the assembly referenced already and you know that the type exists)

Type.GetType(string) is slower;however it is used for late binding - you
don't know actualy if type exists


Ruslan Trifonov
http://xman892.blogspot.com
 
Back
Top