Bug 11132 - In Release Mode, an exception was thrown by the type initializer
Summary: In Release Mode, an exception was thrown by the type initializer
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.4.x
Hardware: PC Mac OS
: Highest normal
Target Milestone: 4.8 (async)
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2013-03-13 15:52 UTC by Allie Miller
Modified: 2013-07-11 11:41 UTC (History)
5 users (show)

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


Attachments
Android Device Logging Output (93.67 KB, text/plain)
2013-03-13 15:52 UTC, Allie Miller
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 Allie Miller 2013-03-13 15:52:45 UTC
Created attachment 3603 [details]
Android Device Logging Output

The project is attached to this bug.

This occurs only in release mode. 

The error occurs only when you add .Where((p) => p.Utilise) in my mobile services query.

The full error message is:
Error
An exception was thrown by the type initializer for Microsoft.
WindowsAzure.MobileServices.FilterBuildingExpressionVisitor

The android device logging ouput for this problem in release mode is attached to this bug as well.
Comment 1 Allie Miller 2013-03-13 15:54:11 UTC
Created attachment 3604 [details]
Ignore this. Wrong!
Comment 3 Jonathan Pryor 2013-05-23 14:31:17 UTC
Alex: I wonder if the issue is that the linker is removing members from e.g. mscorlib.dll.

See for example: Bug #10095.

A potential workaround is a linker script or "falseflag" fix: http://docs.xamarin.com/guides/android/advanced_topics/linking#1.3.falseflag
Comment 4 Alex Rønne Petersen 2013-06-02 14:37:02 UTC
I can't seem to repro this on 4.7.x (master). Will give 4.6.x a shot.
Comment 11 Olivier Ansquer 2013-06-25 02:09:56 UTC
I have done another test today. On 4.7.10 on a Galaxy Note II in Release mode, when I click on the button, I have a message with this error :

An exception was thrown by the type initializer for Microsoft.
WindowsAzure.MobileServices.FilterBuildingExpressionVisitor
Comment 12 Alex Rønne Petersen 2013-06-26 22:06:45 UTC
So here's the deal with this bug, after speaking to Eric.

The version of AMS on the component store should already be fixed so that this bug doesn't happen. This sample comes with an old component, though, hence the exception.

The bug was fixed with a falseflag hack in: https://github.com/xamarin/azure-mobile-services/commit/1e9474196b7b4e15761da1319efcaefc710bfc2c

(So the linker does not need any changes, and we don't need to wait for a new X.A version.)

Long-tern, the plan is that AMS will have a set of platform assemblies. We get to hand Microsoft the Android and iOS assemblies, in which we can put whatever we want (in particular, a falseflag hack to preserve these mehtods).
Comment 13 Olivier Ansquer 2013-06-27 02:52:33 UTC
Thanks.

The problem seems to be solved.
Now my app crashes later (https://bugzilla.xamarin.com/show_bug.cgi?id=12425) :-(.
Comment 14 narayanp 2013-07-09 09:34:26 UTC
Today I have checked this issue with following builds:

All Mac
X.S 4.0.9(build 15)
Mono 3.1.1
Xamarin.Android 4.7.11-42

We have run the attached project in release mode on Android Device HTC ONE version 4.0.4 and we are getting error after clinking on button "An exception was thrown by the type initializer for Microsoft WindowsAzure.MobileServices.FilterBuildingExpressionVisitior"
This is the Logcat for the same: https://gist.github.com/atin360/7db5577f31a6b950776b

Hence reopening this issue
Comment 15 PJ 2013-07-10 19:30:17 UTC
Lal, it looks like that particular issue was resolved by updating the component reference in the attached test case.

Unfortunately, it seems like based on comment 13 you'll get another crash when testing, so we can probably take the verification provided by Olivier for the original issue.