[mono-android] change to a Java cast after 4.2.2

Jonathan Pryor jonp at xamarin.com
Wed Jun 13 18:47:36 UTC 2012


On Jun 13, 2012, at 11:00 AM, John Murray wrote:
> Since installing 4.2.2 I now get an unhandled exc on this code

What is the runtime type of your `sender` parameter?

What release were you using prior to 4.2.2? If you were on 4.0.x previously, you're probably hitting:

	http://docs.xamarin.com/android/Releases/Mono_For_Android_4/Mono_for_Android_4.2#Breaking_Changes

	The various FooEventArgs.V properties have been removed, and their value is now the sender parameter of the EventHandler delegate.

> Which I’ve probably been lucky to get away with before... trouble is I don’t know what to do next to solve it Its a dialog click method

What code are you using garlistclick() with? For example, if I do:

	var builder = new Android.App.AlertDialog.Builder (this);
	builder.SetItems (new[]{"one", "two", "three"}, (o, e) => {
		Console.WriteLine ("Handler invoked! sender.GetType()={0}", o.GetType ().FullName);
	});
	builder.Create ().Show ();

`o.GetType()` is Android.App.AlertDialog. Presumably you're not using AlertDialog.Builder.SetItems(); what are you using?

Thanks,
 - Jon



More information about the Monodroid mailing list