Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IPAddress class serializable?

4 views
Skip to first unread message

George Tsiokos

unread,
Feb 22, 2002, 4:14:26 PM2/22/02
to
Microsoft's documented the IPAddress class as serializable:

[Serializable]
public class IPAddress

When I try to serialize it, I get the following error message:

System.Net.IPAddress cannot be serialized because it does not have a default
public constructor.

Any ideas?


Govind_Kanshi

unread,
Feb 27, 2002, 2:49:52 AM2/27/02
to
Would you mind posting illustrative code which results in the problem ?

Are you trying to remote an instance of IPAddress ?


The following variation seems to work...

IPAddress ip = IPAddress.Parse("157.124.5.25");

IFormatter objFormatterToStream = new SoapFormatter();

Stream toStream = new FileStream("ipdump.xml", FileMode.Create,
FileAccess.Write, FileShare.None);

objFormatterToStream.Serialize(toStream, ip);
toStream.Close();

"George Tsiokos" <geo...@tsioREMOVETHISTEXTkos.com> wrote in message
news:Swyd8.239036$jO5.30...@typhoon.tampabay.rr.com...

George Tsiokos

unread,
Feb 28, 2002, 11:35:22 AM2/28/02
to
[Serializable]
public struct Computer
{
public String name;
public IPAddress ipAddress;
}

This doesn't work, when for example, you try to return this structure from a
method:

private Computer[] computerList;

[WebMethod]
public Computer[] List()
{
return computerList;
}

The error is: System.Net.IPAddress cannot be serialized because it does not


have a default public constructor.


"Govind_Kanshi" <Govind...@email.msn.com> wrote in message
news:uBUAJL2vBHA.2324@tkmsftngp03...

0 new messages