G
Guest
I am having trouble creating an event that is non-serializable in 2.0. In
1.1, I would have just put the [field:NonSerialized] Attribute on the event
as this is the MS-endorsed hack for making it non-serializable.
What I'm trying to do is the following:
public delegate void Notification(object notificationObject);
public interface INotification
{
[field:NonSerialized]
event Notification NotificationEvent;
}
Like I said, this worked perfectly fine in 1.1, but in 2.0 I get the
following warning:
warning CS0657: 'field' is not a valid attribute location for this
declaration. Valid attribute locations for this declaration are 'method,
event'. All attributes in this block will be ignored.
If I change field to method or event, the Attribute barfs saying:
Attribute 'NonSerialized' is not valid on this declaration type. It is valid
on 'field' declarations only.
Are there other ways to do this with an EventHandler on an interface?
1.1, I would have just put the [field:NonSerialized] Attribute on the event
as this is the MS-endorsed hack for making it non-serializable.
What I'm trying to do is the following:
public delegate void Notification(object notificationObject);
public interface INotification
{
[field:NonSerialized]
event Notification NotificationEvent;
}
Like I said, this worked perfectly fine in 1.1, but in 2.0 I get the
following warning:
warning CS0657: 'field' is not a valid attribute location for this
declaration. Valid attribute locations for this declaration are 'method,
event'. All attributes in this block will be ignored.
If I change field to method or event, the Attribute barfs saying:
Attribute 'NonSerialized' is not valid on this declaration type. It is valid
on 'field' declarations only.
Are there other ways to do this with an EventHandler on an interface?