Type.GetType not working for referenced library

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

Guest

Currently im using Type.GetType("namespace.myType") to get the type for the classes, but i want to store the types in a class library insted, however when i do this it will nolonger return a type, the class libary is referenced in the project and i can create any of the types from it... but not using Type.GetType, i am puting the correct string in as i have even taken it from an objects.GetType().Fullname field and it still has not worked...

is there a way of doing this?
 
is there a way of doing this?

If you only specify the type name, Type.GetType() will only look in
the calling assembly and mscorlib.dll, no other assemblies you may
reference.

The solution is to specify which assembly the type is in, in the
format returned by Type.AssemblyQualifiedName.

But since you're referencing the assembly, I don't see why you don't
simply use the typeof operator instead and get compile time checking
of the name as a bonus; typeof(namespace.myType)



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