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

Xml Deserialization with Visual C++ .NET


Hi,

I'm trying to deserialize a VC++ .NET class and am stumped by the following
problem :
In order to create the XmlSerializer you need to pass the type of the object
being created.
The doc shows the example in C# (no C++ available) :

[C#]
MySerializableClass myObject;
// Constructs an instance of the XmlSerializer with the type
// of object that is being deserialized.
XmlSerializer mySerializer = new XmlSerializer(typeof(MySerializableClass));
....
<<
How do I get the System::Type for a class in VC++ ?
I tried Class::GetType() but that generates a compile error C2352 (illegal
call of non-static member function) and it doesn't look like 'typeof' exists.

Help and/or VC++ .NET example would be appreciated!

Jul 21 '05 #1
2 2301
Meta-Meta wrote:
Hi,

I'm trying to deserialize a VC++ .NET class and am stumped by the following
problem :
In order to create the XmlSerializer you need to pass the type of the object
being created.
The doc shows the example in C# (no C++ available) :

[C#]
MySerializableClass myObject;
// Constructs an instance of the XmlSerializer with the type
// of object that is being deserialized.
XmlSerializer mySerializer = new XmlSerializer(typeof(MySerializableClass));
...
<<
How do I get the System::Type for a class in VC++ ?
I tried Class::GetType() but that generates a compile error C2352 (illegal
call of non-static member function) and it doesn't look like 'typeof' exists.


1)
well if the question is how to write the "typeof(...)" statement of
above have a look at

http://msdn.microsoft.com/library/de...ctortopic2.asp

important line is

XmlSerializer* serializer =
new XmlSerializer(__typeof(OrderedItem));

2)
if you mean that you dont know the type of class you are deserializing
at all, there is a problem: you have to.
anyway if you dont know what it is what you are dealing with, what would
you do with it?

if it was the second, be more explicit about what you want to do
cheers,
paul
Jul 21 '05 #2
Paul,

My problem is not with Serializing but deserializing, and not in C# but in
VC++ .NET.
When deserializing, the object does not exist yet, as it will be created as
a result of the deserialization therefore I cannot get the type from the
object (or so argues the compiler ;-) ).
The example supplied in MSDN is in C# and shows the serializer getting the
type from the Class (not object) for deserialization (see C# code snippet in
my first post).
What I do not know how to do in VC++ is to get the type of the Class as
'typeof' does not exist and as I was unable to find an equivalent
method/function for a custon class.

Many thanks,

~Meta-Meta.

"Paul Wohlhart" wrote:
Meta-Meta wrote:
Hi,

I'm trying to deserialize a VC++ .NET class and am stumped by the following
problem :
In order to create the XmlSerializer you need to pass the type of the object
being created.
The doc shows the example in C# (no C++ available) :

[C#]
MySerializableClass myObject;
// Constructs an instance of the XmlSerializer with the type
// of object that is being deserialized.
XmlSerializer mySerializer = new XmlSerializer(typeof(MySerializableClass));
...
<<
How do I get the System::Type for a class in VC++ ?
I tried Class::GetType() but that generates a compile error C2352 (illegal
call of non-static member function) and it doesn't look like 'typeof' exists.


1)
well if the question is how to write the "typeof(...)" statement of
above have a look at

http://msdn.microsoft.com/library/de...ctortopic2.asp

important line is

XmlSerializer* serializer =
new XmlSerializer(__typeof(OrderedItem));

2)
if you mean that you dont know the type of class you are deserializing
at all, there is a problem: you have to.
anyway if you dont know what it is what you are dealing with, what would
you do with it?

if it was the second, be more explicit about what you want to do
cheers,
paul

Jul 21 '05 #3

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

Similar topics

2
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data....
2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
3
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
5
by: Greg Allen | last post by:
I am consuming a web service and using the generated Reference.cs to access the service and the objects associated with it. I have run into a problem where some inherited classes are not being...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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...
0
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,...
0
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...

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.