473,327 Members | 2,016 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,327 software developers and data experts.

Type.GetType(string)

yeah g'day..... is it somehow possible to not include the version & public
key token in the call to Type.GetType(string)

ie something like

Type.GetType("System.Windows.Forms.ListView, System.Windows.Forms");

instead of

Type.GetType("System.Windows.Forms.TextBox,
System.Windows.Forms,Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089");

The first version doesn't work because the type
System.Windows.Forms.ListView doesn't reside in the current assembly or
mscorlib, but i don't want to have to include version information when
retrieving a type.

cheers
the fuzz

Nov 16 '05 #1
3 3248
yeah g'day..... is it somehow possible to not include the version & public
key token in the call to Type.GetType(string)


You can use Assembly.LoadWithPartialName and pass in a partially
qualified assembly name. But see
http://blogs.msdn.com/suzcook/archiv.../30/57159.aspx for good
reasons why you shouldn't do that. Why don't you have a compile time
reference to the assembly instead and use the typeof operator?

Mattias

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

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
You can use Assembly.LoadWithPartialName and pass in a partially
qualified assembly name. But see
http://blogs.msdn.com/suzcook/archiv.../30/57159.aspx for good
reasons why you shouldn't do that. Why don't you have a compile time
reference to the assembly instead and use the typeof operator?


I serialize user controls at design time to an xml document which is stored
in a db, and provide a runtime designer so that our customers can manipulate
the layout of our program (but not add new controls). At runtime when a form
is loaded the xml document is recursed and the child controls properties are
set according to how the customer has modified the layout. kinda simplified
xaml

An xml document in its simplest form looks like the following at the moment:

<Test.Login assembly="DisplayEngine">
<System.Windows.Forms.ListView assembly="System.Windows.Forms,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="listView1" view="Details" location="360, 32" tabIndex="7" />
</Test.Login>

I worry that when new versions of the .net framework come out this will pose
an upgrade challenge because of the embedded versioning in the assembly
attribute. eg. my program will want to run on v2 which i know i can enforce
through the <supportedRuntime> & <requiredRuntime> attributes, but the xml
will still contain references to v1.1. do you think this will be an issue,
also wouldn't third party UI controls on my forms also have the same problem
here?

thanks,
the fuzz
Nov 16 '05 #3
I worry that when new versions of the .net framework come out this will pose
an upgrade challenge because of the embedded versioning in the assembly
attribute. eg. my program will want to run on v2 which i know i can enforce
through the <supportedRuntime> & <requiredRuntime> attributes, but the xml
will still contain references to v1.1. do you think this will be an issue,
also wouldn't third party UI controls on my forms also have the same problem
here?

The framework's unification feature should ensure that the
System.Windows.Forms assembly version matching the framework version
you're running under is loaded, even if you're requesting an older
version. For more details on unification policy, see

http://weblogs.asp.net/junfeng/archi...23/268388.aspx
http://blogs.msdn.com/alanshi/archiv.../15/73244.aspx

Mattias

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

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

Similar topics

3
by: Kendall Gifford | last post by:
Greetings. While trying to get a simple app working, I've been forced to delve into embedded and/or linked resources a bit. I read all the reference for the System.Resources namespace as well as...
2
by: Sean | last post by:
Hello, I have a function in C# that accepts a stored proc name and an array of parameters, and then returns a dataset, which works just fine. I have converted the function to VB: Public Shared...
6
by: tshad | last post by:
The error I am getting is: ******************************************************************* Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not...
4
by: Sparky Arbuckle | last post by:
I am looping through a listbox collection to build a SQL string that will be used to delete items from a database. I have tried many variances of the code below but have had no luck. The code below...
9
by: Ben | last post by:
Hello, I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem: I have some information in an array:...
1
by: Jason Chan | last post by:
in asp.net 2.0, Page.RegisterClientScriptBlock is replaced by Client.RegisterClientScriptBlock function signature: Client.RegisterClientScriptBlock(Type, String, String) what should i put...
9
by: Gugale at Lincoln | last post by:
In my code Type.GetType(text) works when text="System.IO.File". However, it doesn't work when text="System.Windows.Forms.Button". In general it works for classes in System.dll assembly. Is there...
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}"...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.