Bug 13480 - [Async] AsyncTask InvalidCastException
Summary: [Async] AsyncTask InvalidCastException
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.8.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-07-25 15:15 UTC by Pierce Boggan [MSFT]
Modified: 2013-09-03 15:44 UTC (History)
7 users (show)

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

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:
RESOLVED FIXED

Description Pierce Boggan [MSFT] 2013-07-25 15:15:42 UTC
Test Project: Attached.
Exception Encountered:
Thread started: #2
[MonoDroid] UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
[MonoDroid] at Android.OS.AsyncTask.n_DoInBackground_arrayLjava_lang_Object_ (intptr,intptr,intptr) [0x00008] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/3f1c339b/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.OS.AsyncTask.cs:185
[MonoDroid] at (wrapper dynamic-method) object.35a4ff3a-9872-466d-b54b-7616d3319b7f (intptr,intptr,intptr) <IL 0x00017, 0x00023>
[mono] 
[mono] Unhandled Exception:
[mono] System.InvalidCastException: Cannot cast from source type to destination type.
[mono] at Android.OS.AsyncTask.n_DoInBackground_arrayLjava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native__params) [0x00008] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/3f1c339b/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.OS.AsyncTask.cs:185 
[mono] at (wrapper dynamic-method) object:35a4ff3a-9872-466d-b54b-7616d3319b7f (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Cannot cast from source type to destination type.
[mono-rt] at Android.OS.AsyncTask.n_DoInBackground_arrayLjava_lang_Object_ (IntPtr jnienv, IntPtr native__this, IntPtr native__params) [0x00008] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/3f1c339b/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.OS.AsyncTask.cs:185 
[mono-rt] at (wrapper dynamic-method) object:35a4ff3a-9872-466d-b54b-7616d3319b7f (intptr,intptr,intptr)


Release Information:
Xamarin studio 4.0.10
Xamarin mono for android 4.8
Windows 8 64 bit
Comment 3 Jonathan Pryor 2013-08-13 18:09:46 UTC
Fixed in monodroid/8a80c942.
Comment 4 Gerco Brandwijk 2013-08-30 02:05:13 UTC
Which version of Mono.Android is monodroid/8a80c942? Can I download this fix now?
Comment 5 Jonathan Pryor 2013-08-30 09:50:07 UTC
monodroid/8a80c942 will be included in the 4.8.3 release.

Once 4.8.2 makes it into the beta channel, we'll start releasing alphas for 4.8.3.
Comment 6 Jonathan Pryor 2013-08-30 09:50:53 UTC
As a workaround, don't use System.String with AsyncTask. Try using Java.Lang.String.