473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing "Type" class

Hi All,

Was anybody able to serialize the "Type" class properly using
XmlSerializer() ....
Want to serialize and deserialze the Type in a string form, but can this be
done ?

myobj.Type = typeof(System.S tring) as <type>System.St ring</type>

thanks a ton.
Nov 12 '05 #1
3 4775
Maersa wrote:
Was anybody able to serialize the "Type" class properly using
XmlSerializer() ....


AFAIK that's impossible due to security reasons.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2
If all you want is the type name, can you use a buddy member that depends on
the actual type?

public class MyType {
[XmlIgnore] // this is not serialized
public System.Type ActualTypeInsta nce;

public System.String TypeName {
get {
return ActualTypeInsta nce.FullName;
}
set {
ActualTypeInsta nce= System.Type.Get Type(value);
}
}
}

-Dino
"Oleg Tkachenko" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message
news:On******** ******@tk2msftn gp13.phx.gbl...
Maersa wrote:
Was anybody able to serialize the "Type" class properly using
XmlSerializer() ....


AFAIK that's impossible due to security reasons.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #3
The XmlSerializer is not really intended for anything but binding XML to
simple data classes, check [0] for a more detailed discussion.

Why do you want to serialize a Type object to a string anyway? There isn't
much state information in a Type object that's interesting to serialize. If
you need to store information about what Type you were dealing with, then
storing the Type's FullName property will suffice.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

[0] http://www.topxml.com/xmlserializer/...le_classes.asp

"Maersa" <ma*****@hotmai l.com> wrote in message
news:Oa******** ******@TK2MSFTN GP12.phx.gbl...
Hi All,

Was anybody able to serialize the "Type" class properly using
XmlSerializer() ....
Want to serialize and deserialze the Type in a string form, but can this be done ?

myobj.Type = typeof(System.S tring) as <type>System.St ring</type>

thanks a ton.

Nov 12 '05 #4

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

Similar topics

6
14306
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? WD
0
7370
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http channal hosting into IIS. There is a class B which is also available through remoting hosted on IIS on the same URI. B creates new of A inside a function....
5
33512
by: Lou Pecora | last post by:
g++ compiler error question. I have a container C whose constructor takes a class B that is inherited from an abstract class A. So I have the line of code: B binstance; C cinstance(binstance); The compiler gives the error,
6
10764
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new FileStream(NavCmdFile, FileMode.Create, FileAccess.Write, FileShare.None); XmlSerializer xmlFmt = new XmlSerializer(someObject.GetType());
6
3578
by: Kay | last post by:
Hi all, In vb6, I can define a custom type like this: Private Type uClient sName As String sMonday As Double sMondayHeadCnt As Integer End Type
15
5268
by: Cruella DeVille | last post by:
I'm trying to implement a bookmark-url program, which accepts user input and puts the strings in a dictionary. Somehow I'm not able to iterate myDictionary of type Dict{} When I write print type(myDictionary) I get that the type is "instance", which makes no sense to me. What does that mean? Thanks
3
2468
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
3
10425
by: phil | last post by:
I have written a little application that can grab part of a page from a web site. I then want to take this result and be able to serialize it so that it can be stored as XML. I am storing these "ResultNodes" as System.Xml.XmlElements but when I try and serialize (serialise) my result object I get the following exception: ...
0
160
by: Jeff Louie | last post by:
Robert.. You can use interfaces or an abstract base class to abstract out the functionality of the plug ins. You then program to the abstraction. In the case of an interface, you program to the public view, the interface. The interface defines a contract between the user of your plug in class and any concrete implementation of the class....
0
7612
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...
0
7924
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. ...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
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
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.