473,378 Members | 1,280 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,378 software developers and data experts.

How can i see if an object is Xml Serializable at runtime?

I am looking for a way to determine in RunTime if a given object is Xml
Serializable (short of trying to serialize it to xml and catching the
exception).

Is this possible?

Since an object must have a Default Constructor to be XmlSerializable I have
tried something like:

Type valueType = aRandomObject.GetType();
bool isXmlSerializable = valueType.IsClass && !valueType.IsValueType
? valueType.GetConstructor(new Type[]{}) != null : true;

but this is not correct. Am I on the right track or missing something
obvious...?

Any ideas?

Thanks in advance
Tim
Dec 21 '05 #1
2 1656
What about Type.IsSerializable?

Dan

"TimJR" wrote:
I am looking for a way to determine in RunTime if a given object is Xml
Serializable (short of trying to serialize it to xml and catching the
exception).

Is this possible?

Since an object must have a Default Constructor to be XmlSerializable I have
tried something like:

Type valueType = aRandomObject.GetType();
bool isXmlSerializable = valueType.IsClass && !valueType.IsValueType
? valueType.GetConstructor(new Type[]{}) != null : true;

but this is not correct. Am I on the right track or missing something
obvious...?

Any ideas?

Thanks in advance
Tim

Dec 21 '05 #2
No, Type.IsSerializable is for Binary serialization, not Xml Serialization so
it does not identify if an object (or type) is xml serializable.

"Dan Kelley" wrote:
What about Type.IsSerializable?

Dan


Dec 21 '05 #3

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

Similar topics

1
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object.cs in rotor. What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What I don't...
0
by: Kenneth Baltrinic | last post by:
I am getting the following error when deserializing an object that has a couple of dozen dependant objects in its object graph. Anyone who can suggest where I might begin to look to resolve problem...
4
by: Heinz | last post by:
Hi all, How can I create a method that returns a copy of an object, not a reference to the object itself. Thanks ! Heinz
0
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object class (Object.cs in rotor). What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What...
5
by: Mark Rae | last post by:
Hi, Can anyone please tell me how to convert an object say, a System.Web.Mail.MailMessage object, to a byte array and then convert the byte array to a Base64 string? Any assistance gratefully...
3
by: Jason | last post by:
Hi prolly a simple solution...how do i make a "copy" of an existing object eg object obj1 = new object(); object obj2 = obj1; if i change a property in obj2, it also changes obj1, since...
3
by: Gelios | last post by:
Hi All! Probably my question is newbie but anycase. Should I do object that I want to pass as parameter to remoting object serializable? For Example: //server public class MyServerObject {
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.