473,405 Members | 2,210 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,405 software developers and data experts.

How to Serialize Class with System.Net.IPAddress Attribute?

I have a an attribute within a Serializable class that is of type
System.Net.IPAddress. When I try to serialize the class, I get the
following error:

System.InvalidOperationException: Cannot serialize member
'SerializationTest.ConfigurationProperties.Connect ionAddress' of type
'System.Net.IPAddress', see inner exception for more details.

System.InvalidOperationException: System.Net.IPAddress cannot be
serialized because it does not have a parameterless constructor.

What workarounds are there?
Dec 6 '06 #1
2 6302
O.B. wrote:
I have a an attribute within a Serializable class that is of type
System.Net.IPAddress. When I try to serialize the class, I get the
following error:

System.InvalidOperationException: Cannot serialize member
'SerializationTest.ConfigurationProperties.Connect ionAddress' of type
'System.Net.IPAddress', see inner exception for more details.

System.InvalidOperationException: System.Net.IPAddress cannot be
serialized because it does not have a parameterless constructor.

What workarounds are there?
Well, one workaround is to change the type from IPAddress to a string.
That seems to work for now. If there is something better, please let me
know.
Dec 6 '06 #2
Hello,
>What workarounds are there?
You could implement ISerializable, which allows you to completely redefine
the process of serialization and store data in whatever format you like.
You could then use a string or an integer (or a few integers, if you're
thinking IPv6) to store the IP address data and reconstruct it on the
deserialization side.
Oliver Sturm
--
http://www.sturmnet.org/blog
Dec 6 '06 #3

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

Similar topics

7
by: grwalker | last post by:
I have some classes that have the <Serializable()> attribute applied, which of course by default serializes the class properties as elements. What I would like to do is to be able to override this...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
5
by: Brad | last post by:
I would like to serialize an arraylist of objects to xml so I can store the xml in a database column. How would I code the serializing and deserializing? Below is a (overly) simple, incomplete...
0
by: elziko | last post by:
I have a complex class that inherits from System.Windows.Forms.UserControl in VS2005. I am trying to serialize this class but I just get an InvalidOperationException stating: "There was an...
1
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. ...
6
by: tshad | last post by:
I had asked about this before, but have been unable to solve the problem. Could this be a problem with Web Services? I have 4 web services that I reference in this object. There is only one...
8
by: Andy B | last post by:
I have the following code in a default.aspx web form page_load event. There seems to be a problem with line 5 (NewsArticle.Date = line). //create a news article NewsArticle NewsArticle = new...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.