Type.GetType returns null

mmingfeilam
mmingfeilam used Ask the Experts™
on
i notice that if i have a class that i created within my current assembly, Type.GetType works.  But if it's a class located in an assembly that i am referencing, then i keep getting a null.  can someone tell me why this is the case and if there is any alternative to invoking an object:

myType = Type.GetType("TypeName");
                IMyType myObj = Activator.CreateInstance(myType) as IMyType;
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2015

Commented:
Use the fully qualified name. Something like:

   System.data, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

http://msdn.microsoft.com/en-us/library/k8xx4k69.aspx

Author

Commented:
i did that but now i am getting:
 
Type adapterType = Type.GetType("SRT.HeartBeat.EAI.Adapter.FtpsAdapter, Version=3.1.655.3, Culture=neutral, PublicKeyToken=2d302914a71c7ad5");
 [System.IO.FileLoadException] = {"The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)":null}
Before you could create an instance thro Reflection, you should load the required assembly.

http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx

Author

Commented:
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial