473,779 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Serialize Class with System.Net.IPAd dress Attribute?

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

System.InvalidO perationExcepti on: Cannot serialize member
'SerializationT est.Configurati onProperties.Co nnectionAddress ' of type
'System.Net.IPA ddress', see inner exception for more details.

System.InvalidO perationExcepti on: System.Net.IPAd dress cannot be
serialized because it does not have a parameterless constructor.

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

System.InvalidO perationExcepti on: Cannot serialize member
'SerializationT est.Configurati onProperties.Co nnectionAddress ' of type
'System.Net.IPA ddress', see inner exception for more details.

System.InvalidO perationExcepti on: System.Net.IPAd dress 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
4357
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 behavior at runtime to serialize the properties as attributes. I have been exploring the XMLAttributesOverrides classes and examples which claims: "you can create one set of serializable classes, but serialize the objects in multiple ways....
5
24723
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 s); public void Deserialize(Stream s); Within the MyUserControl class, there is a field of type MyInnerClass
10
4166
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; string s_FinalFileName; try
7
3548
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 TypeConverter other than ReferenceConverter to be put in viewstate." I've included the <Serializable()> attribute, but I'm still getting the same error. The class is below ... as you can see it contains a Collection, two
5
8038
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 example of what I'd want to accomplish. Thanks Brad Example
0
1506
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 error reflecting type 'Eatec.R5000.Report.ReportControl'" ....the InnerException states:
1
1468
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. Database.cs DatabaseFactory.cs DatabaseProviderFactory.cs DBCommandWrapper.cs
6
492
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 class. I have an object I am unable to put in my session. I have others that have no problem. The difference is the the one I am having problems with was created in VS 2003. The others were created using DW and compiling using the commandline...
8
2006
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 NewsArticle(); NewsArticle.Body = "This is a test news article..."; NewsArticle.Title = "Testing XML";
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.