Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / April 2005

Tip: Looking for answers? Try searching our database.

Xml Deserialization with Visual C++ .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Meta-Meta - 28 Apr 2005 22:29 GMT
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!
Paul Wohlhart - 28 Apr 2005 23:43 GMT
> Hi,
>
[quoted text clipped - 14 lines]
> 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/default.asp?url=/library/en-us/cpref/html/frlr
fsystemxmlserializationxmlserializerclassctortopic2.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
Meta-Meta - 30 Apr 2005 00:06 GMT
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.

> > Hi,
> >
[quoted text clipped - 36 lines]
> cheers,
> paul

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.