Type.GetType returns null

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.
 
R

Ruslan Trifonov

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top