liuhaipeng905 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 1 forks source link

XML Example Requirement #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Running the getXML function results in failure on SerializeToString line

What is the expected output? What do you see instead?
Expecting serialize (json) string in result variable.
Exception raised due to XmlReader type:
A first chance exception of type 'System.TypeInitializationException' occurred 
in ServiceStack.Text.dll

What version of the product are you using? On what operating system?
ServiceStack.Text.dll 1.37, XP Pro SP3, .NET 3.5

Please provide any additional information below.
I expect the exception is raised due to an unsuitable type (i.e. XmlReader). 
Would appreciate example of getting the standard XmlReader (or derivative) into 
this library call.

Original issue reported on code.google.com by peter.ro...@googlemail.com on 22 Jul 2010 at 3:55

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Peter,

Unfortunately serializing from an XmlReader is not supported. TypeSerializer 
can serilaize standard POCO's or pure collection data classes like 
Dictionary's/Lists etc.

I suggest that you manually populate a POCO class from the reader then 
serialize that. 

If you have control over your tables, you may be able to take advantage of 
OrmLite - which is just a set of lightweight extensions over IDbCommand that 
takes care of populating POCO's from a datareader. 

Cheers,
Demis

Original comment by demis.be...@gmail.com on 22 Jul 2010 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by demis.be...@gmail.com on 11 Aug 2010 at 3:14