473,809 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetDomai n().GetAssembli es(), 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 15287
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.GetTyp e, having
loaded the assembly.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3508
by: JohnnySparkles | last post by:
Hi everyone, I'm currently writing an application which uses the XmlSerializer class to serialize/deserialize objects to/from xml. Now when deserializing an XmlDocument back into the object, I'm using the System::Type::GetType(String* typeName) to create a Type* needed to construct the XmlSerializer. The typeName argument is taken from the XmlDocument and consists of the
1
3222
by: hazz | last post by:
"Value cannot be null.\r\nParameter name: type" is the exception thrown after the CreateInstance method below. Type t = Type.GetType(GetConfigValue("PasswordProvider")); IPasswordProvider ppdr= (IPasswordProvider)Activator.CreateInstance(t); GetConfigValue DOES return the correct value from the config file - "namespace.DBPassword, namespace" It appears that Type.GetType is NOT finding the assembly whose name is the
2
4014
by: david.kao | last post by:
I have web service always return a string in Xml format, and I have the code at client side translates this return string into correct value. For example: my web service returns a <ret type=”System.int”>1</ret>. So my client logic will translate this into integer value of one by using Type.GetType() function. Likewise, if my web service returns a <ret type=”System.String”>abc</ret>, my client again translates this into string type....
4
2675
by: Craig | last post by:
Hi I have a class in the App_Code location of my web project. example: namespace Company.AppName.Objects { public class ObjectA { public ObjectA(){ }
1
341
by: Suresh | last post by:
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
7
7821
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}" As far as I know yet -- hence this question -- there is no 'one solution fits all', but instead there are several parts that have to be put together to check. What I have so far is, and would like as much feedback as possible to ensure I've...
1
2160
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems down the line... What happens when my code is run on a station that only has framework 3.0 or 4.0, and this assembly, with version number defined for 2.0.0.0 , isn't available. ...breaks? Second question: Does an assembly's PublicKeyToken change...
1
3535
by: Jamey McElveen | last post by:
I have the typename of a form I wish to to load dynamically (example:MyCompany.Client.Win.Security.Detail.SysUserDetailForm). However, when I call Type.GetType(typeName) it return null I am assuming since I did not use the full name which is not available. I wrote the below method to return the Type but I have some concerns with it. First is there an eaiser way to do this that I am missing. Second, I am concerned about the...
4
13156
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, I'd like to create a generic algorithm to analyse an enum's elements for custom attributes. All I have at hand is is a type name to create an enum type info from. But if I call Type.GetType(enumTypeName) it returns null or throws an exception. Can anyone enlighten me on how to walk through an unknown enums elements to retrieve their custom attributes?
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.