473,473 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with Serializable class implementing INotifyPropertyChange

I have a class that is marked as Serializable that implements
INotifyPropertyChanged.

private event PropertyChangedEventHandler _PropertyChanged;
public event PropertyChangedEventHandler PropertyChanged
{
add { _PropertyChanged += value; }
remove { _PropertyChanged -= value; }
}

When I compile the class, FxCop complains:

"Field _PropertyChanged is a member of type User, which is serializable, but
is of type System.ComponentModel.PropertyChangedEventHandler, which is not
serializable. Add the NonSerializedAttribute to _PropertyChanged."

If I add the NonSerialized attribute to the event declaration...

[NonSerialized()]
private event PropertyChangedEventHandler _PropertyChanged;

It complains:
Attribute 'NonSerialized' is not valid on this declaration type. It is valid
on 'field' declarations only.

Is there any way around this?
Nov 17 '05 #1
0 2788

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

Similar topics

0
by: Orly Junior | last post by:
Gentlemen, I am working with .Net Remoting, but I am running into many problems. Probably due to the fact that I am not very experienced with that new technology. The question is... after...
0
by: okinrus | last post by:
Can someone take a look at this code and figure out why Serializable_base::add_serializer throws std::bad_alloc. The problem seems to be the compiler because msvc++ 7.1 says...
2
by: Andrew G. J. Fung | last post by:
Can anyone please explain to me why the code below throws an exception? It seems to occur when deserializing an instance of a subclass, whose base class holds a struct, where said struct holds an...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
1
by: Frank Rizzo | last post by:
What is the performance impact of setting a attribute on a class? Is there a performance win if I remove the attribute? I am doing some perf profiling and realized that all my strongly type...
5
by: Makarand | last post by:
Hi Friends I have collection class implementing from IList. Problem I am facing is I am not able to put this object in ViewState(though it is going in Session). When I try to do this it gives...
0
by: Don Leckie | last post by:
Hi, I hope someone can really help me. This problem has me stumped. I have class "A" that does not implement Serializable, but class "A" subclasses Serializable class "B". Therefore, when...
0
by: sandycormie | last post by:
Hello I suspect the answer is going to be no, but... I have a class that contains a property defined as an abstract class. I would like to control the format of the generated XML to include a...
0
by: sandycormie | last post by:
Hello I suspect the answer is going to be no, but... I have a class that contains a property defined as an abstract class. I would like to control the format of the generated XML to include a...
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
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...
1
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
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...
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,...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.