By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

Serializing "Type" class

P: n/a
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.String) as <type>System.String</type>

thanks a ton.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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 ActualTypeInstance;

public System.String TypeName {
get {
return ActualTypeInstance.FullName;
}
set {
ActualTypeInstance= System.Type.GetType(value);
}
}
}

-Dino
"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:On**************@tk2msftngp13.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

P: n/a
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*****@hotmail.com> wrote in message
news:Oa**************@TK2MSFTNGP12.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.String) as <type>System.String</type>

thanks a ton.

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.