This is because of a recent modification to Xamarin.iOS.
Traditionally MonoTouch has allowed managed objects to be created without a native peer. The behavior has however been inconsistent between types, and in the case of types from third-party libraries it would result in instances which would, if used, most likely crash the process with a stack overflow. So the default behavior has been changed: an exception will be thrown if a native peer cannot be created for a managed object. As the exception message also mentions this behavior is controlled by the value MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure - set it to false to return to the old behavior.
In your case you get the exception because you're trying to create a UIAlertViewDelegate instance when there is no corresponding Objective-C class (since UIAlertViewDelegate
is an Objective-C protocol, not an Objective-C class).
The solution is simple, as user1010710 already mentioned, just use null
instead of new UIAlertViewDelegate()
. The result is identical: in previous versions of Xamarin.iOS you would end up with a managed UIAlertViewDelegate instance whose Handle is IntPtr.Zero - and that IntPtr.Zero value would be passed to the native constructor. This is exactly what happens when you pass null
.