473,387 Members | 1,536 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,387 software developers and data experts.

Error when trying to Inherit a control and then make it Serializab

Hi. I am trying to do something that seems very simple. I want to create a
class that inherits from the ListViewItem Control so that I can add a few
custom properties to it. I then want to make it serializable so that I can
save the ListViewItems contained in the ListView. My code snippet is this:

[Serializable()]
public class test : System.Windows.Forms.ListViewItem
{
public test(string s, int i): base(s, i) {}
protected test(SerializationInfo si, StreamingContext context)
: base(si,context){}
//additional properties here.
}

When attempting to compile I get the error message:
....\MainForm.cs(1077):
'System.Windows.Forms.ListViewItem.ListViewItem(Sy stem.Runtime.Serialization.SerializationInfo,
System.Runtime.Serialization.StreamingContext)' is inaccessible due to its
protection level

I added the second constructor
"protected test(SerializationInfo si, StreamingContext context)
: base(si,context){}"
in an attempt to fix a problem that was occuring during runtime. I was
getting an exception error that the class could not be deserialized.

Thanks for the help in advance.
Nov 16 '05 #1
2 1428
Kelly schrieb:
I then want to make it serializable so that I can
save the ListViewItems contained in the ListView.


AFAIK, serialization requires each ancestor class to be serializable as
well.

Christian
Nov 16 '05 #2
Christian,

I believe the ListViewItems class IS serializable. I have successfully
serialized and deserialized this class. I just run into prolbems when I try
to inherit it.

-Kelly

"Christian Gudrian" wrote:
Kelly schrieb:
I then want to make it serializable so that I can
save the ListViewItems contained in the ListView.


AFAIK, serialization requires each ancestor class to be serializable as
well.

Christian

Nov 16 '05 #3

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

Similar topics

16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
1
by: Mark | last post by:
I have .aspx code-behinds that inherit from the class below. The code runs just fine, but the form designer bombs at design time when trying to view the .aspx page in VS.NET 2003. If I comment...
5
by: Francis Shanahan | last post by:
Folks, I have a base page which is the grand-daddy of all my pages. It inherits from System.UI.Web.Page From this I inherit a layout page. From this I inherit the individual pages themselves....
1
by: AP | last post by:
Hi, I am trying to inherit from a base class and use that as my code behind class for various forms that have common functionality. The problem is that when I try to view the form in the form...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
3
by: Antoon Pardon | last post by:
In a number of cases I have a program that looks like the following. for case in all_cases: try: treat(case) except Exception, ErrInfo: generate_traceback() The idea is to get as much...
2
by: ticars | last post by:
I'm getting a weird error when trying to access a user control from within a base page during runtime. Here's what I have: I have a master page with a user control on it. I then have a few...
4
by: SteveT | last post by:
I have written a control that does some base functionality. I then wrote a control that inherits from it so that I can make several unique versions which behave differently. To do this the...
5
by: Bob Cox | last post by:
I am getting the error: Invalid number : color fuchsia is not a color value : fuchsia from the W3C CSS validator, yet I am sure the same CSS validated ok previously. The offending CSS is: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.