473,789 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type.GetType(st ring)

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

ie something like

Type.GetType("S ystem.Windows.F orms.ListView, System.Windows. Forms");

instead of

Type.GetType("S ystem.Windows.F orms.TextBox,
System.Windows. Forms,Version=1 .0.5000.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9");

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 3285
yeah g'day..... is it somehow possible to not include the version & public
key token in the call to Type.GetType(st ring)


You can use Assembly.LoadWi thPartialName 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.o rg> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
You can use Assembly.LoadWi thPartialName 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="Displ ayEngine">
<System.Windows .Forms.ListView assembly="Syste m.Windows.Forms ,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
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 <supportedRunti me> & <requiredRuntim e> 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 <supportedRunti me> & <requiredRuntim e> 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
5659
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 all the material within the "Resources and Localization..." tutorial. While I'm confident I now know completely how to accomplish my original, simple task of embedding some icons into my assembly and use of the same at runtime, I realize I've a...
2
5889
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 Function GetDataSet(ByVal storedProcedure As String, ByRef parameterArray As Object()) As DataSet
6
5444
by: tshad | last post by:
The error I am getting is: ******************************************************************* Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not valid. Source Error: Line 144: firstName.text = ClientReader("firstName") Line 145: lastName.text = ClientReader("lastName")
4
1840
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 gives an error: Cast from type 'ListItem' to type 'String' is not valid. When i do a response.write(s) the item at the top row displays correctly. Here is the code I am using:
9
1941
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: sdist(i). The information is a string. When I run the application, I don"t have problem for compilation but during te execution, I have the error Cast from type 'Object()' to type 'String' is not valid on the line: sdistinguishedname = Sdist(i). Or...
1
3192
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 on the Type?
9
13279
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 anyway I can make it work for classes in System.Windows.Forms.dll assembly? Thanks SG
7
7818
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...
8
3284
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 as well as for "System.IO.Stream" or "System.Globalization.CultureInfo". Does that related to the constructor of XmlReader being not public?
0
9666
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
9511
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
10200
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...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
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
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.