472,989 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

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("SampleLib.MyClass");

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

SampleLib.MyClass ptrMyClass = new SampleLib.MyClass();
Type myType = Type.GetType("SampleLib.MyClass");

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 3949
The MSDN documentation for System.Type.GetType() explains what's going on
here:
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemtypeclassgettypetopic1.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.MyClass
class exists in a DLL called MyLibrary, then you would write this code to
look it up:

Type myType = Type.GetType("SampleLib.MyClass,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*******@hotmail.com (Jean Stax)
| Newsgroups: microsoft.public.dotnet.languages.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**********@google.com
| NNTP-Posting-Date: Sat, 25 Oct 2003 19:51:25 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!newsfeed.icl.net!newsfeed.fjserv.net!news.max well.syr.edu!postnews1.goo
gle.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194051
| X-Tomcat-NG: microsoft.public.dotnet.languages.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("SampleLib.MyClass");
|
| My guess was that the function fails because my library isn't loaded
| yet.
| So I wrote the following:
|
| SampleLib.MyClass ptrMyClass = new SampleLib.MyClass();
| Type myType = Type.GetType("SampleLib.MyClass");
|
| 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
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,...
7
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
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...
12
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. ...
13
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
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,...
1
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...
11
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...
8
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.