473,569 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ListViewI tem
{
public test(string s, int i): base(s, i) {}
protected test(Serializat ionInfo si, StreamingContex t context)
: base(si,context ){}
//additional properties here.
}

When attempting to compile I get the error message:
....\MainForm.c s(1077):
'System.Windows .Forms.ListView Item.ListViewIt em(System.Runti me.Serializatio n.Serialization Info,
System.Runtime. Serialization.S treamingContext )' is inaccessible due to its
protection level

I added the second constructor
"protected test(Serializat ionInfo si, StreamingContex t 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 1436
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
7203
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
2152
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 out the single line of code below, then there is no error. I posted the error message below - it implies that this code is being run at design time,...
5
1738
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. The problem: My pages can no longer be brought up in the designer. I'm using Visual Studio 2002 and these pages are written in asp.NET with the...
1
1148
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 designer that I get an error: " could not be loaded." Why am I getting this error? Adam
5
3612
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 New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE")...
3
1404
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 information as possible when something goes wrong but at the same time treat as many cases as possible.
2
2213
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 webforms that provide content to the master page. All of these webforms inherit from the same basepage which I created. Within that base page I'm...
4
8012
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 inherited control uses generics. When I compile this code the "Dispose()" routine of my inherited class generates a compiler error. ...
5
2161
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: a:active {
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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. ...
0
8138
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...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
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...
0
3657
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...
1
2117
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
0
946
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...

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.