469,602 Members | 1,998 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

SoapFormatter not outputing properties

Hi, I have a class derived from ApplicationException as below (excuse
formatting):

[Serializable()]

public class MyException : ApplicationException {

public string CompanyName {

get {return Application.CompanyName;}

}

public string ProductName {

get {return Application.ProductName;}

}

public string ProductVersion {

get {return Application.ProductVersion;}

}

}

I am serializing it as follows:

IFormatter formatter = new SoapFormatter();

Stream stream = new FileStream(dlgSave.FileName, FileMode.Create,
FileAccess.Write, FileShare.None);

formatter.Serialize(stream, _ex);

stream.Close();

However, the extra properites I have added to the class are not getting
output. How come?

Thanks.
Nov 11 '05 #1
1 1353
The SoapFormatter does not serialize properties, it only serializes the
fields that reflect the actual state of the object.

The XmlSerializer behaves the way you are looking for. It has a bunch of
other limitations though, so be careful before you switch from one to the
other.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"James Willock" <ja***@dot.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
Hi, I have a class derived from ApplicationException as below (excuse
formatting):

[Serializable()]

public class MyException : ApplicationException {

public string CompanyName {

get {return Application.CompanyName;}

}

public string ProductName {

get {return Application.ProductName;}

}

public string ProductVersion {

get {return Application.ProductVersion;}

}

}

I am serializing it as follows:

IFormatter formatter = new SoapFormatter();

Stream stream = new FileStream(dlgSave.FileName, FileMode.Create,
FileAccess.Write, FileShare.None);

formatter.Serialize(stream, _ex);

stream.Close();

However, the extra properites I have added to the class are not getting
output. How come?

Thanks.

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jarda | last post: by
reply views Thread by seckley | last post: by
reply views Thread by GrandpaB | last post: by
4 posts views Thread by laplas | last post: by
5 posts views Thread by =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.