473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2495
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.orgwrote in message
news:eY**************@TK2MSFTNGP02.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**********@confideltial.comwrote:
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.com>
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
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,...
1
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 =...
6
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 =...
4
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...
4
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
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...
1
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...
1
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...
6
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...
7
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}"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.