Bug 29722 - [ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: No event handler has been added to the ShouldChangeTextInRanges event.
Summary: [ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: No event handler has bee...
Status: VERIFIED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.0.0
Hardware: PC Windows
: High normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-05-04 17:01 UTC by Jon Douglas [MSFT]
Modified: 2015-10-01 14:47 UTC (History)
3 users (show)

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


Attachments
Reproduction (13.61 KB, application/x-zip-compressed)
2015-05-04 17:01 UTC, Jon Douglas [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

Description Jon Douglas [MSFT] 2015-05-04 17:01:14 UTC
Created attachment 11058 [details]
Reproduction

*Description

After upgrading to X.Mac 2.0, it seems that subscribing to a TextDidChange event on a NSTextView will crash an application with the following exception:

[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: No event handler has
been added to the ShouldChangeTextInRanges event.
at AppKit.NSTextView+_NSTextViewDelegate.ShouldChangeTextInRanges
(AppKit.NSTextView textView, Foundation.NSValue[] affectedRanges,
System.String[] replacementStrings) [0x00022] in
/Users/builder/data/lanes/1503/8a0e7bca/source/maccore/src/build/mac/mobile/AppKit/NSTextView.g.cs:3902
at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain
(int,string[])
at AppKit.NSApplication.Main (System.String[] args) [0x00041] in
/Users/builder/data/lanes/1503/8a0e7bca/source/maccore/src/AppKit/NSApplication.cs:94
at TextViewTest.MainClass.Main (System.String[] args) [0x00007] in
/Users/jlipsky/Projects/TextViewTest/Main.cs:12

*Reproduction

1) Run TextViewTest solution
2) Enter text into the textbox
3) You should run into the exception above

*Version Information

=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: 9091fd92-0b4a-4688-960c-73bfd6f1a240
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: 8.10.0.267 (Business Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Mac ===

Version: 2.0.0.262 (Business Edition)

=== Xamarin.Android ===

Version: 5.1.0.115 (Business Edition)
Android SDK: /Users/jonathandouglas/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.10.2
Darwin Jonathans-Mac-mini.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Feb 26 19:26:47 PST 2015
    root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Comment 1 Chris Hamons 2015-05-05 11:46:35 UTC
Until we look into a fix for this, you can work around it by not using the C# events and doing something like:

https://gist.github.com/chamons/bc7d951b009cab8b7a63

It looks like my fixing to make the C# events less broken exposed this binding bug (which has been around forever).
Comment 2 Jon Lipsky 2015-05-05 11:49:09 UTC
Ok...  I was hoping to not have to do that, as I use those specific events all over the place.
Comment 3 Chris Hamons 2015-05-05 11:52:21 UTC
Here's another work around for you that might be less painful:

Adding

customTextView.ShouldChangeTextInRanges += (textView, affectedRanges, replacementStrings) => true;

standardTextView.ShouldChangeTextInRanges += (textView, affectedRanges, replacementStrings) => true;

also "fixes" it.
Comment 4 Chris Hamons 2015-05-05 12:07:23 UTC
Fixed in master / d82617ab63e85ee80ff3ee4aa0296f6bb4539d4b.

This will be part of XM 2.2, later this year.
Comment 5 Rajneesh Kumar 2015-10-01 14:47:30 UTC
I have checked this issue with the cycle 6 builds XS 5.10 (build 811) + X.M 2.4.0.79 + Mono 4.2.1.59 and observed that this issue has been fixed and no longer exist with this build. Now I an able enter text into the textbox without any exception. Please refer the screencast given below: http://www.screencast.com/t/IMgLOGjb9BL

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

Environment Info:

=== Xamarin Studio ===

Version 5.10 (build 811)
Installation UUID: 0b7eaebc-a0ed-4b58-81df-91e378cad28c
Runtime:
	Mono 4.2.1 (explicit/328e048)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010059

=== Xamarin.Profiler ===

Version: 0.0.0.0
Location: /Applications/XamarinProfiler.Mac.app/Contents/MacOS/XamarinProfiler.Mac

=== Apple Developer Tools ===

Xcode 7.0 (8227)
Build 7A220

=== Xamarin.Mac ===

Version: 2.4.0.79 (Starter Edition)

=== Xamarin.iOS ===

Version: 9.0.1.20 (Starter Edition)
Hash: d8e9592
Branch: master
Build date: 2015-09-18 23:22:05-0400

=== Xamarin.Android ===

Version: 5.1.6.7 (Starter Edition)
Android SDK: /Users/Admin_Mac/Desktop/Anddk/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		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)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)

SDK Tools Version: 24.3.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 22.0.1

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)

=== Xamarin Android Player ===

Version: 0.6.1
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 510000811
Git revision: 34cd31ea72536afab530c14d9220b286075e83cd
Build date: 2015-09-30 10:40:37-04
Xamarin addins: 8e6fccfc0c19a7e0b7b11be925f09751d827eb5c
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.11.0
Darwin Admin-Macs-Mac-mini.local 15.0.0 Darwin Kernel Version 15.0.0
    Wed Aug 26 16:57:32 PDT 2015
    root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64