Okay, I really hope all these hard drive crashes aren't because of me. It seems like my posts are always the ones that get lost when something like that happens... :-( how sad.
Anyway, I'd like to re-post the question and "half-answer" I put up yesterday morning, partially because it may help someone else down the line, and partially because I still have some unresolved questions. Here goes...
I added a custom event to my business object following the pattern that Rocky covers in the book on page 101-102. So far so good. I create a form with a private "datasource" object (based on the one with the custom event) and declare it as "WithEvents". I set the private data source to the parameter that I pass in to the form's constructor, and then call BeginEdit on the object (almost exact replica of the way the ProjectEdit form works in the ProjectTracker App). In my form, I also have an event handler for the custom event in the business object. Code compiles fine, but when the form is actually shown, I get a "Form is not declared as serializable" (or some variant thereof) error. If I take away the event handler in the form, I get no errors--form displays fine. If I pop in an event handler for the PropertyChanged event, I get no errors either.
Rocky had suggested that I trace through the thing with the debugger, which I did. What I found was that at the call of BeginEdit, it was for some reason seeing the "mNonSerializableHandlers" as an available field to clone. As soon as I put the <NotUndoable()> attribute in front of it, then things worked fine. What I still don't understand is why the PropertyChanged custom event works fine WITHOUT the NotUndoable attribute, but my custom event seems to require it. Any ideas?
John Delano
Aha! That makes a ton of sense. Perfect!
Thanks,
John Delano
Copyright (c) Marimer LLC