OnApplyChangeFailed not called if no subscribers - bug? RRS feed

  • Question

  • Hi,

    (this applies to Microsoft.Synchronization.Data.Server v.

    In the N-tier conflict resolution example, I had a problem with not getting my breakpoint in DbServerSyncProvider.OnApplyChangeFailed hit. However, when I hooked up an event handler to the event, my breakpoint was hit.

    Examining the sourcecode for DbServerSyncProvider in Reflector, I noticed this:

    ApplyChangeFailedEventArgs args = this.CreateApplyChangesFailedEvent(tableMetadata, syncConflict, error, syncSession); 

    So by design, OnApplyChangeFailed does not get called if there are no subscribers to the event. This goes against standard coding practices, forcing subclasses of DbServerSyncProvider to listen on own events.

    I consider this a bug. Or am I missing something?



    • Moved by Hengzhe Li Friday, April 22, 2011 7:50 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, November 11, 2008 1:28 PM

All replies

  • What set of standard coding practices are you refereing to?


    It seems that you could just set a break point on the if statement shown above if all you want to do is debug.



    Tuesday, November 18, 2008 10:34 PM
  • I too see this as "broken by design".


    Throughout my .NET developments, I have always chosen to override "On..." methods when deriving classes rather than attaching events, for example (for the benefit of the poster above) overriding the OnLoad method of a Form class.


    Unless there is a specific overhead in the creation of the various EventArgs derivatives, what is the purpose of providing an overridable OnApplyChangeFailed method (or any of the others) - it can never be called unless there is an event handler attached to the associated ApplyChangeFailed event (as stated above).


    I should point out that this also applys throughout the rest of the Sync Services for ADO.NET (I have not checked the rest of the Sync Services Framework).


    Also for the poster above, the example code shown is from the Sync Services DLL and, since no source code is available, it is not possible to put a breakpoint on the "if" statement.


    Friday, November 21, 2008 10:46 AM