Bug 18454 - Can't add an event handler to a button after removing an event handler from that button.
Summary: Can't add an event handler to a button after removing an event handler from t...
Status: VERIFIED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.0.x
Assignee: Chris Hamons
URL:
: 18439 ()
Depends on:
Blocks:
 
Reported: 2014-03-18 20:16 UTC by Jon Goldberger [MSFT]
Modified: 2015-03-02 13:50 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project - MonoMac, XamMac, and iOS projects included (51.49 KB, application/zip)
2014-03-18 20:16 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Comment 1 Jon Goldberger [MSFT] 2014-03-18 20:17:10 UTC
From case:
I am trying to add and remove event on button click. But what happens is
that, first time event gets added and after we remove event
programmatically and then add it again, nothing happens.
Comment 2 Jon Goldberger [MSFT] 2014-03-18 20:22:58 UTC
I have reproduced this issue and supplied a test project with XamMac, MonoMac, and iOS versions.

In iOS version, adding and removing event handlers works as expected. After removing the event handler you can read the event and everything works as expected. Adding the event handler multiple times makes the event handler fire multiple times. The same holds true holds true for removing event handlers, except that when there are two event handlers left (all of the same name) removing again removes the last two event handlers simultaneously. 

In the XamMac or MonoMac versions, adding an event handler works. removing the event handler works, but trying to re-add the event handler does not work. Again, all using the same event handler name. In addition, unlike on XI, adding the event handler multiple times only makes the event handler fire once no matter how many times you add the event handler.
Comment 3 Jon Goldberger [MSFT] 2014-03-18 20:51:22 UTC
Created a workaround:
https://gist.github.com/jgold6/9633327
Basically just removing the button from the view and adding a new button and adding the event handler to the new button. Clunky, yes.
Comment 4 Ram Chandra 2014-07-17 05:58:38 UTC
I have checked this issue and I am also getting the same behavior.

I tried the attached sample in XamMac and observed that when I adding an event handler it is working. when I call that event handler it is working as expected. When I remove the event handler it is also working and after removing the event handler when I again add the event handler and try to call that event handler, now it is not working no matter how many time I try to add the add event handler.

I have also tried the iOS version and it works as expected as mentioned on Comment 2.

Screencast: http://www.screencast.com/t/OsDzcgxdZZ9t

Environment Info:

=== Xamarin Studio ===

Version 5.1.3 (build 0)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.6.0 ((no/5ff701f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000037

=== Xamarin.Android ===

Version: 4.12.5 (Enterprise Edition)
Android SDK: /Users/jatin66/Desktop/Backup/android-sdk-macosx
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: 7.2.5.5 (Enterprise Edition)
Hash: 87026b6
Branch: 
Build date: 2014-07-02 19:39:08-0400

=== Xamarin.Mac ===

Version: 1.8.0.8

=== Build Information ===

Release ID: 501030000
Git revision: 4676331632b3e5820ed4a92576594309907d778c
Build date: 2014-07-10 20:42:24-04
Xamarin addins: 571e972d874f74867110c205fc25b56048e7e93a

=== Operating System ===

Mac OS X 10.9.3
Darwin Jatin66s-iMac.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Comment 5 Rajneesh Kumar 2014-08-06 10:53:33 UTC
*** Bug 18439 has been marked as a duplicate of this bug. ***
Comment 6 Timothy Risi 2015-02-25 12:59:52 UTC
Fixed in master / 9cb7be4b9fb51f8ff14f47de3fee8bf08baf7560
Comment 7 Rajneesh Kumar 2015-03-02 13:50:45 UTC
I have checked this issue with the following builds:

=== Xamarin Studio ===
Version 5.8 (build 1043)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
Mono 4.0.0 ((detached/2634099)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400000017
 Apple Developer ToolsXcode 6.1 (6604)
Build 6A1052d
Xamarin.Mac Version: 1.13.1.417 (Business Edition)
=== Build Information ===
Release ID: 508001043
Git revision: eeba4b77cc5ab021f9c5e2bddf16272e1f6b75d9
Build date: 2015-03-02 06:49:10-05
Xamarin addins: a58814e6e6034bf1169e758b92ead093a3f40404
Operating SystemMac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

I observed that this issue is working fine. Now, I can add an event handler to a button after removing an event handler from that button.
Please refer the screencast : http://www.screencast.com/t/w5qbFsmd2f

This issue has been fixed, hence I am closing this issue.