System.Type.GetType problem

  • Thread starter Thread starter Jimi
  • Start date Start date
J

Jimi

What am I doing wrong?
I'm trying to get a type object for a type which is not currently
loaded in my project (otherwise I'd use "typeof").

System.Type oType = System.Type.GetType("SomeNamespace.SomeType");

But oType is always "<undefined value>" after this line.

Any help is much appreciated.
 
Jimi said:
What am I doing wrong?
I'm trying to get a type object for a type which is not currently
loaded in my project (otherwise I'd use "typeof").

System.Type oType = System.Type.GetType("SomeNamespace.SomeType");

But oType is always "<undefined value>" after this line.

Any help is much appreciated.

You say "not currently loaded in my project." That would be why it is returning null. Are you loading the assembly the type is
located in at runtime? It has to know somehow what that type is.
 
I've tried that - even though I had hoped to get away from loading it
- even when the assembly is loaded I still get "undefined value" for
oType:

System.Type oType = System.Type.GetType("SomeNamespace.SomeType");
 
What am I doing wrong?

You must include the assembly name too, otherwise the runtime doesn't
know where the type is implemented


Type.GetType("SomeNamespace.SomeType, YourAsmName, Version=1.2.3.4,
Culture=null, PublicKeyToken=0123456789ABCDEF");



Mattias
 

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

Back
Top