Bug 27580 - [Mac] JavaScriptSerializer throws exception when running in release mode
Summary: [Mac] JavaScriptSerializer throws exception when running in release mode
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 1.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
Depends on:
Reported: 2015-03-02 17:41 UTC by Dominic N [MSFT]
Modified: 2015-03-02 22:01 UTC (History)
1 user (show)

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

Test Project (24.38 KB, application/zip)
2015-03-02 17:41 UTC, Dominic N [MSFT]

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:

Description Dominic N [MSFT] 2015-03-02 17:41:03 UTC
Created attachment 10120 [details]
Test Project

## Overview

A customer has contacted us with an issue in Xamarin.Mac where running an app in release mode with the attached code generates a JavaScriptSerializer error. 

## Steps to reproduce

1. Open attached sample
2. Run in release mode

## Expected results

App runs in debug mode and release mode

## Actual results

App runs in debug mode and crashes in release mode

## Version information

=== Xamarin Studio ===

Version 5.7.2 (build 7)
Installation UUID: 92d53c23-9d93-4b30-8388-524e9b083152
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)

Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 9905782
Build date: 2015-02-26 11:05:07-0500

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/username/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
Java SDK: /usr
No Java runtime present, requesting install.

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 507020007
Git revision: dcf3f486177d3e625349b51a8f3be807e3fa7712
Build date: 2015-02-24 09:14:27-05
Xamarin addins: ea7c65bb7876e4a876ab365208e94acdf8f330ef

=== Operating System ===

Mac OS X 10.10.0
Darwin PC.local 14.0.0 Darwin Kernel Version 14.0.0
Fri Sep 19 00:26:44 PDT 2014
root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 1 Chris Hamons 2015-03-02 22:01:16 UTC
This is due to System.Configuration:

[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer ---> System.Configuration.ConfigurationErrorsException: Type 'System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' not found.

You can work around this by setting the Linker Behavior to None.

You can also work around this via something like this:

see: http://developer.xamarin.com/guides/cross-platform/advanced/custom_linking/

I started an xml file here:

        <assembly fullname="System.Web.Extensions">
		<type fullname="System.Web.Script.Serialization.JavaScriptSerializer" preserve="fields"></type>
		<type fullname="System.Web.Configuration.*" preserve="fields">
			<method name=".ctor" />

but it is incomplete. You can bang on it some more if they really need linking. Please note, System.Configuration is very dynamic in nature, so this may be brittle.