473,854 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type.GetType for referenced library returns undefined value

Hi !

I created a sample library project. In my second project I reference
this library
and make the following call, which returns "undefined value":

Type myType = Type.GetType("S ampleLib.MyClas s");

My guess was that the function fails because my library isn't loaded
yet.
So I wrote the following:

SampleLib.MyCla ss ptrMyClass = new SampleLib.MyCla ss();
Type myType = Type.GetType("S ampleLib.MyClas s");

Unfortunately, this doesn't solve my problem. Type.GetType of any new
type defined in my second project
works just fine.

Any ideas ?

Thanks
Nov 15 '05 #1
1 4011
The MSDN documentation for System.Type.Get Type() explains what's going on
here:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemtype classgettypetop ic1.asp

The documentation says: "If typeName includes only the name of the Type,
this method searches in the calling object's assembly, then in the
mscorlib.dll assembly. If typeName is fully qualified with the partial or
complete assembly name, this method searches in the specified assembly."

So, as you noted, you are able to look up types in the same assembly, but
not in a referenced assembly. To look up a type in a reference assembly,
add the referenced assembly name to the string. If your SampleLib.MyCla ss
class exists in a DLL called MyLibrary, then you would write this code to
look it up:

Type myType = Type.GetType("S ampleLib.MyClas s,MyLibrary");
--
Eric, Visual Studio Enterprise Frameworks and Tools

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
| From: je*******@hotma il.com (Jean Stax)
| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
| Subject: Type.GetType for referenced library returns undefined value
| Date: 25 Oct 2003 12:51:24 -0700
| Organization: http://groups.google.com
| Lines: 22
| Message-ID: <df************ **************@ posting.google. com>
| NNTP-Posting-Host: 212.150.123.82
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google. com 1067111485 3928 127.0.0.1 (25 Oct 2003
19:51:25 GMT)
| X-Complaints-To: gr**********@go ogle.com
| NNTP-Posting-Date: Sat, 25 Oct 2003 19:51:25 +0000 (UTC)
| Path:
cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!newsfeed.i cl.net!newsfeed .fjserv.net!new s.maxwell.syr.e du!postnews1.go o
gle.com!not-for-mail
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1940 51
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
|
| Hi !
|
| I created a sample library project. In my second project I reference
| this library
| and make the following call, which returns "undefined value":
|
| Type myType = Type.GetType("S ampleLib.MyClas s");
|
| My guess was that the function fails because my library isn't loaded
| yet.
| So I wrote the following:
|
| SampleLib.MyCla ss ptrMyClass = new SampleLib.MyCla ss();
| Type myType = Type.GetType("S ampleLib.MyClas s");
|
| Unfortunately, this doesn't solve my problem. Type.GetType of any new
| type defined in my second project
| works just fine.
|
| Any ideas ?
|
| Thanks
|

Nov 15 '05 #2

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

Similar topics

1
3652
by: Ekips | last post by:
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... ...
7
1708
by: Alphonse Giambrone | last post by:
How can I convert a string to a different type based on another string or other variable? For instance, instead of Dim i as Integer i = ctype("1000", Integer) I would like to do
2
3314
by: S. Justin Gengo | last post by:
Hi, I've created a component that allows me to store database information for various types of databases my company uses. It uses a collection for each type of database. Everything is working perfectly except when the component is deleted from the page. Here are the details. I add the component to the page from the toolbox and then add items using the collection editor. I can delete those items from the collection using the collection...
12
3811
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. 1. The Deserialization goes like: #Region " Load "
13
12407
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
0
1685
by: CrispinH | last post by:
Hi I've just upgraded some Type Editors from 1.1 to 2.0 and whilst they compile OK, I'm not getting any results in the test harness PropertyGrid. Usually when you select a particular property, the ellipsis appears at the end of the cell and this is not heppening. I was therefore wondering if there had been changes in TypeEditors between ..NET versions 1.1 and 2.0 that I hadn't hear about.
1
3536
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...
11
1793
by: Dinsdale | last post by:
I am trying to determine what the current cast of an object is. Essentially, if I use GetType, it always returns the original type of the object created but I want to know what the current cast of the object is (i.e.: is it still cast as a Derived class, or is it cast as a Base class?) Here is some pseudo code to show the example. Class Base .... End Class
8
3288
by: Martin Eckart | last post by:
Hi folks, Who can explain me why the following expression does not result in getting the correct type, but null: Type t = Type.GetType("System.Xml.XmlReader"); For "System.String" it works as well as for "System.IO.Stream" or "System.Globalization.CultureInfo". Does that related to the constructor of XmlReader being not public?
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9751
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
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9513
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 project—planning, coding, testing, and deployment—without 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...
0
7081
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
5941
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4560
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3186
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.