[RESOLVED] Trying to add events

[RESOLVED] Trying to add events

Old forum URL: forums.lhotka.net/forums/t/1304.aspx


vbdotnetguy posted on Friday, September 22, 2006

I have a class that inherits the BusinessBase class.  I'm doing something that I would like to raise my own events for.  however i'm getting the following error

Type 'TimeCardWin' in Assembly 'ShumakerLTM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

how can i add my own events and not get this error message?

Brian Criswell replied on Friday, September 22, 2006

Well, TimeCardWin needs the [Serializable] attribute to remove the error.  But what is TimeCardWin, and what do you mean by adding your own events?  Are you following the pattern that Rocky used in Csla.Core.BindableBase?

ajj3085 replied on Friday, September 22, 2006

Are you creating new events on TimeCardWin which others can listen to?

vbdotnetguy replied on Friday, September 22, 2006

TimeCardWin is the form the custome events are in the TimeCard BO.  Also in this class there is a BusinessListBase object and I'm getting the ListChanged event for the BusinessListBase object.  This is where I want to fire my own events to indicate that a property changed in the list.  Unless i'm going about this completely the wrong way

Brian Criswell replied on Friday, September 22, 2006

Okay, it sounds like your events have not been set up to separate serializable and non-serializable listeners.  Form is not serializable.  You can either define your events similarly to how Rocky defined Csla.Core.BindableBase.PropertyChanged, or I think you can mark your event with the [NotSerializable] attribute.

RockfordLhotka replied on Friday, September 22, 2006

You can't just mark the event with the attribute. The only real solution is what I do in BindableBase. Plus you also need to mark the NonSerializable delegate field with NotUndoable.

vbdotnetguy replied on Friday, September 22, 2006

Thank you sooooooooo much... I what you did in the BindableBase, but still couldn't get it to work and was going to post again seeing what I was still doing wrong.  Then I read what you posted  and saw that you posted that I would need the NotUndoable.  Added that and it works... Big Smile [:D]  Thank you very much Rocky.

RockfordLhotka replied on Friday, September 22, 2006

Now that I think about it further, you should probably mark _both_ delegate fields as NotUndoable. Neither one should be affected by n-level undo. I need to make this same change to the new Saved event in version 2.1 as well.
 
Rocky
 


From: vbdotnetguy [mailto:cslanet@lhotka.net]
Sent: Friday, September 22, 2006 2:38 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Trying to add events

Thank you sooooooooo much... I what you did in the BindableBase, but still couldn't get it to work and was going to post again seeing what I was still doing wrong.  Then I read what you posted  and saw that you posted that I would need the NotUndoable.  Added that and it works... Big Smile <img src=" src="/emoticons/emotion-2.gif">  Thank you very much Rocky.



Copyright (c) Marimer LLC