473,799 Members | 3,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetType problem

Hi,

I have a certain assembly that needs to create instances of objects where
the object class is passed as a string (e.g. "System.Drawing .Bitmap"). I
have found that calling "GetType" on this string, returns null.

Naturally, I suspect that because the this assembly doesn't reference the
assembly containing "System.Drawing .Bitmap", the type cannot be found and
thus I'm getting null in the GetType.

My question is, how would I solve this. I thoughtof extending my classes so
that assembly references can be given from an outside source and the type
sought there by local GetType.

My question is how do I achieve that? Is there a "GetType" for an assembly?

ron
Aug 24 '06 #1
3 2521
Ron,
>My question is how do I achieve that? Is there a "GetType" for an assembly?
There's System.Assembly .GetType if that's what you're looking for.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 24 '06 #2
I already found the app domain which I query for runtime assemblies and for
each of those I do a "GetType" until I get what I need.

thanks
Ron

"Mattias Sjögren" <ma************ ********@mvps.o rgwrote in message
news:eY******** ******@TK2MSFTN GP02.phx.gbl...
Ron,
>>My question is how do I achieve that? Is there a "GetType" for an
assembly?

There's System.Assembly .GetType if that's what you're looking for.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Aug 24 '06 #3
Ron M. Newman <co**********@c onfideltial.com wrote:
I have a certain assembly that needs to create instances of objects where
the object class is passed as a string (e.g. "System.Drawing .Bitmap"). I
have found that calling "GetType" on this string, returns null.

Naturally, I suspect that because the this assembly doesn't reference the
assembly containing "System.Drawing .Bitmap", the type cannot be found and
thus I'm getting null in the GetType.
I know you've got the answer now, but it's got nothing to do with
referenced assemblies. Unless you include the full assembly name in the
call to Type.GetType, only the current assembly and mscorlib are
searched.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 24 '06 #4

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
4009
by: Jean Stax | last post by:
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.
6
6968
by: h | last post by:
Hi! I have a user control called ListItemControl. This works ok: ListItemControl li = new ListItemControl(); When I iterate with Enumerator through all controls using: IEnumerator e = pnlList.Controls.GetEnumerator(); while (e.MoveNext())
4
2731
by: RichB | last post by:
Hello, The .NET application I have just installed at a client web site is throwing a strange error. At first the applications works without any problems, but after 10 mins or so Access denied error messages are thrown. The application, web based, late binds to a series of assemblies, none of which are in the GAC. I have configured the application to impersonate the IIS user and have set the user to have access to all relevant...
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(){ }
4
2870
by: Howard Kaikow | last post by:
For the code below, for both appWord and gappWord, I get the error "Public member 'GetType' on type 'ApplicationClass' not found" I realize the test for appWord is superflous as the parameter is passed in as a known type, but gappWord is has a scope of the class, so a test of the type is valid (making believe the sub does not know the pre-ordained type). TypeOf returns Word.Application. TypeName returns ApplicationClass.
1
1371
by: Jennyfer Barco | last post by:
Hello I have a question. I have a project called "Primary" and in that project I have a reference to a Com application called "engine". In "engine" I have a function that does many things and calls other local functions for several purposes. In one of those functions I have the code: Dim myType As Type Application_AssemblyName = "Primary"
1
1495
by: dcs | last post by:
Hi, Can someone please help. I have a class that contains the following Structure (called MyStructure) and sub (called MainSub). And this 1st class inherits a 2nd class that contains a sub called Get_Values_From_MyStructure. My problem is in sub Get_Values_From_MyStructure. Since Get_Values_From_MyStructure is inherited by many different classes, its parameter i_obj_Structure will contain various Structure definitions. And thats a problem...
6
1461
by: Paul | last post by:
I have two projects in one solution. One is called Frontier and holds all my base user controls, classes, etc. that are used over multiple applications. The second is my application project (OCFU) which holds the forms and code that the users run. I need to instantiate a new form only given the form's name in a string. In the calling form in the OCFU project I used the following code: Dim objNewForm As Object =...
7
7819
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...
0
9687
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
9541
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
10484
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
10251
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...
0
9072
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
5463
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...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.