StrataFrame Forum

BOTranslations on SFUserControl Mishandled when using Miscellaneous Events

http://forum.strataframe.net/Topic31135.aspx

By Kirk M Sherhart - 4/16/2012

I believe I've found a bug when using BOTranslations on SFUserControls involving the BusinessLayer.CopyEventHandlersFrom method.

I have a BO that implements a "Miscellaneous Event" (in my case, the FieldPropertyChanging event.) The BO is used both on a form and a SFUserControl, using BOTranslations. During the form's initialization, a call is made eventually to the BusinessObjectTranslator.TranslateBusinessObjects method, which eventually calls the BusinessLayer.CopyEventHandlersFrom method.

For all the "standard" events, CopyEventHandlersFrom calls the GetValidInvocationList method to weed out any handlers that shouldn't be copied. However, the code which handles the Miscellaneous events doesn't do this.  Instead, it just makes a direct copy of the destination BO's miscellaneous events to the sourceBO.  

Therefore, CopyEventHandlersFrom leaves the sourceBO with duplicated events (sourceBO's original event + destBO's event).  When the event is raised, a call is eventually made to the destBO's event handler, which promptly causes an exception.

(Just for comparison, when using a CFD, the routine BusinessLayer.PushEventsFrom is called, which handles this situation correctly)