469,600 Members | 2,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

Type.GetType returns null

Hi,

I have an C# CSEXE.exe (CSexe.cs) and a CSDll.dll
(CSdll.cs). exe is compiled with a reference to dll.
Calling for the class Type defined in CSDLL.dll using
Type.GetType( "myDLLnamespace.CSDll" ) returns null. I
made sure that the fully qualified class defined in the
dll is case-sensitive.

// CSEXE.exe
// CSexe.cs
namespace myEXEnamespace {
public class CSexe {

public static main()
{
//This returns null
Type csdllType = Type.GetType
( "myDLLnamespace.CSdll" );
}
}
}

namespace myDLLnamespace {
public class CSdll {

public CSdll(){}

public int myFunc(int a)
{
return a*a;
}
}
}

Can anyone tell why does the Type.GetType() returns null.
I have even checked the assemblies in the current domain
by using Thread.GetDomain().GetAssemblies(), I could find
the CSDll.dll loaded in the Default appdomain. Is it a
bug in C# or am I missing something.

Thanks
Suresh
Jul 21 '05 #1
1 13417
Suresh <su****@hotmail.com> wrote:
I have an C# CSEXE.exe (CSexe.cs) and a CSDll.dll
(CSdll.cs). exe is compiled with a reference to dll.
Calling for the class Type defined in CSDLL.dll using
Type.GetType( "myDLLnamespace.CSDll" ) returns null. I
made sure that the fully qualified class defined in the
dll is case-sensitive.


The problem is that Type.GetType, when just given a class name and not
the assembly information, only looks in the current assembly and
mscorlib. You could either fully specify the name (including the
assembly name, version etc) or you could use Assembly.GetType, having
loaded the assembly.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by JohnnySparkles | last post: by
2 posts views Thread by david.kao | last post: by
4 posts views Thread by Craig | last post: by
1 post views Thread by Suresh | last post: by
1 post views Thread by Jamey McElveen | last post: by
4 posts views Thread by =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.