mishal153
mishal153

Reputation: 1554

WPF click event triggering twice under specific build enviroment

We are facing a strange problem. We have a user control written in WPF and we have added a click event handler in the xaml file. On local system it works as expected. But when the build is generated on the server (where we have the code repository), we notice that the resultant build has a bug. The bug is that the click event is generated twice everytime for this control. We are using a OpenFileDialog in the event handler function for browsing images. We noticed that local system build through VS uses CSC.exe for building while on the server we use MSBuild.exe. So we tried building using MSBuild on our local system too. But bug does not reproduce on local system. Building the code on the server system using VS also does not reproduce the bug. Therefore the only way to repro the bug is to generate the automated build on the server. We have tried comparing the IL code of both dlls (buggy and non-buggy). We checked IL code for the event handler function. The IL code is identical.

I do not suspect our code since the bug does not reproduce on our local system under any circumstances. Please let me know if you need any more inputs/details.

Any help will be appreciated.

Thanks, Mishal

Upvotes: 0

Views: 451

Answers (2)

mishal153
mishal153

Reputation: 1554

BTW this was 'fixed' (workaround) quite easily. Bug disappears if the click event handler for the button is added from code rather than from XAML :| I believe it might be some MS bug in XAML loader. I am not sure if others ar efacing this too but we are actively facing this bug in more than 2 places. The one missing link is under what circumstances the bug appears. Till now we have seen this in case of button only. Not sure where else this appears

Upvotes: 0

Brian
Brian

Reputation: 118855

(VS is using MSBuild.)

In VS, set

Tools\Options\Project and Solutions\Build and Run\MSBuild project output verbosity

to 'diagnostic', then clean the project, build it, and capture the log from the output window.

Compare with output of "msbuild.exe /v:diag ..." run on the server.

Hopefully that will find the source of the disparity.

Upvotes: 1

Related Questions