473,395 Members | 1,696 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 fails for StringCollection

I tried using Type::GetType on
S"System.Collections.Specialized.StringCollection" , but it returned NULL.
The only way it worked was when I used the fully qualified name, including
the assembly name, version, and token information.

This seems like a bug to me, since StringCollection is part of system.dll,
and I thought types in this DLL were automatically located using GetType, but
perhaps I am mistaken.
It seems to me that requiring all this information as part of the GetType
call is just asking for your code to be non-portable.

Does anyone have any more information on this? Any help is appreciated.
Jul 21 '05 #1
3 1535
This seems like a bug to me, since StringCollection is part of system.dll,
and I thought types in this DLL were automatically located using GetType, but
perhaps I am mistaken.
Yes you were. The documentation states pretty clearly that GetType
only looks in the calling assembly and in mscorlib.dll unless you
include the assembly name.

It seems to me that requiring all this information as part of the GetType
call is just asking for your code to be non-portable.


So why are you using Type::GetType instead of referencing System.dll
and using the __typeof keyword?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
> So why are you using Type::GetType instead of referencing System.dll
and using the __typeof keyword?


I have been developing exclusively on Unix for 13 years. This is my first
foray into Windows, so I am a relative newbie.

It would help me greatly if you could elaborate on using __typeof. In my
case, I needed to create a DataColumn for a DataTable, so I had no object to
refer to when creating the column type. Are there any advantages to using
one over the other?

Thanks,
- Jon
Jul 21 '05 #3
Jonathan,
It would help me greatly if you could elaborate on using __typeof.
__typeof is a MC++ operator that returns the System::Type for a given
type known at compile time. It's documented here

http://msdn.microsoft.com/library/en...rf__typeof.asp

Are there any advantages to using one over the other?


__typeof gives you compile time checking. Type::GetType on the other
hand is more dynamic.

Mattias

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

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

Similar topics

2
by: AlexS | last post by:
I have app, which has usings for System.Windows.Forms But when I do Type.GetType("TreeView") or use full class name for TreeView I get null. Why? Anything I miss? What are the rules of use...
4
by: audipen | last post by:
I have a problem with System.Type.GetType method. If you try out the following code in C# console app .. System.Type t = System.Type.GetType("System.DateTime"); System.Type t1 =...
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 =...
2
by: Dennis Myrén | last post by:
Hi. I want to know why it is not possible to specify (or determine) the capacity for a System.Collections.Specialized.StringCollection. I guess the StringCollection would be the better choice...
2
by: Dan | last post by:
Hi, Is it possible to iterate through a StringCollection ? I have the following code but "row" always seems to contain the values of rowValues2 Thanks for any input, Danny
1
by: Juan Francisco Figueroa Perez | last post by:
Hi all: I have a StringCollection property like this: public class FormExito : Form { ................ ................ private StringCollection FEditar;
8
by: Naz | last post by:
Hi, I am new in C# and converting a program from delphi to C#. I have to store a list of strings in memory and also need to save the strings to disk at the end. I use StringCollection and my...
3
by: Jonathan | last post by:
I tried using Type::GetType on S"System.Collections.Specialized.StringCollection", but it returned NULL. The only way it worked was when I used the fully qualified name, including the assembly...
2
by: eSapient | last post by:
I have a case where a C# dll is being consumed by an unmanaged C++ executable. One of the dll methods returns a StringCollection object. What are the requirements for the C++ executable in terms of...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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.