Bug 36250 - Linker: crash with a Dictionary<string, string> member and using "Link SDK assemblies only"
Summary: Linker: crash with a Dictionary<string, string> member and using "Link SDK as...
Alias: None
Product: Android
Classification: Xamarin
Component: Tools and Addins ()
Version: 6.0.0
Hardware: PC Windows
: High major
Target Milestone: C6SR1
Assignee: Radek Doulik
Depends on:
Reported: 2015-11-25 11:50 UTC by Dimitar Dobrev
Modified: 2016-03-21 18:22 UTC (History)
7 users (show)

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

repro case (30.34 KB, application/zip)
2015-12-01 00:19 UTC, Peter Collins

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 Dimitar Dobrev 2015-11-25 11:50:37 UTC
I installed Xamarin yesterday and started getting this regression with our production build which employs the Mono Linker with the setting of "Link SDK assemblies only":


Constructor on type 'System.Runtime.Serialization.CollectionDataContract+GenericDictionaryEnumerator`2[[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' not found.

while serialising this class:

    [DataContract(Namespace = "...")]
    public class SearchRequest : ...

        public string Query { get; private set; }

        public List<string> Users { get; private set; }

        public List<string> Filters { get; private set; }

        public Dictionary<string, string> Parameters { get; private set; }


     string xmlData;
     using (MemoryStream memoryStream = new MemoryStream())
	dataContractSerializer = new DataContractSerializer(typeof(SearchRequest));
	dataContractSerializer.WriteObject(memoryStream, req);
    	xmlData = Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int) memoryStream.Length);

Given the error message, the problem is because of Dictionary<string, string> Parameters.

We are forced to downgrade because of this. Please fix it as soon as possible.
Comment 1 Peter Collins 2015-12-01 00:19:46 UTC
Created attachment 14048 [details]
repro case

I can confirm this behavior is a regression introduced in XA 6.0.

#### Steps to reproduce ####
1. Deploy the attached test case in Release mode.
2. Tap the button.
Comment 2 Radek Doulik 2015-12-02 17:38:00 UTC
fixed in master by c18fa83b31226a9213e382854abb03c303cac346
Comment 3 Abhishek 2015-12-03 11:50:38 UTC
I have check this issue and able to reproduce this issue at my end.

Screencast for Mac XS: http://www.screencast.com/t/RatUVvxyhJHV
Screencast for Window VS: http://www.screencast.com/t/gnpUy9OuBe
Screencast for Window XS: http://www.screencast.com/t/4JNWmNDvjMt8

To verify this issue I have checked this issue with the latest master build:
mono-android-6.0.99-248_f1e0185cd56d8e614b69c8f7bf1a9484adbf6274. Now this issue is working fine on Mac XS. 

Screencast for Mac XS: http://www.screencast.com/t/J8d2DKGh.

But this issue still exist on Windows Environment. I have checked this issue with the latest master build on Windows:

Screencast for Windows XS: http://www.screencast.com/t/VCcdUSJIGFG
Screencast for Windows VS: http://www.screencast.com/t/07MefqYwFqY

Comment 4 Radek Doulik 2015-12-03 15:30:21 UTC
VS build contains older XA. Hopefully it will work once the VS is updated.
Comment 5 Evgeniy Zverev 2015-12-08 13:49:45 UTC
The bug is still there in Xamarin.Android (Visual Studio).
Comment 6 Peter Collins 2015-12-08 16:57:42 UTC
@Evgeniy We have a patch that fixes the issue, but it has not yet been applied to our upcoming service release. It should be available (initially in the Alpha channel) within the coming weeks.
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-08 17:24:37 UTC
*** Bug 36710 has been marked as a duplicate of this bug. ***
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-08 23:01:20 UTC
## Status update

The candidate fix for this issue is not included in the first Alpha version of "Cycle 6 – Service Release 1" published today. It will likely be included in the next Alpha version of "Cycle 6 – Service Release 1."

(This is just to add some standard wording that I'm also using on a few other bugs. For this particular bug this status update is a duplicate of the information in Comment 6.)
Comment 9 Abhishek 2015-12-16 16:57:44 UTC
I have checked this issue with the latest C6SR1 build both on mac and Windows:
Xamarin.VisualStudio_4.0.1.46_05924d217095caf1f27f953f4c50ac766f16fbcb. Now this issue is working fine both on Mac and Windows environment.

Screencast for VS: http://www.screencast.com/t/XEIAIwM0P6O
Screencast for Windows XS: http://www.screencast.com/t/aHaT00RLMQj

Comment 10 Abhishek 2015-12-16 16:59:42 UTC
An Update to the build:

Comment 11 Dimitar Dobrev 2015-12-18 03:27:29 UTC
When is there going to be a stable release with this fix? It's a blocker.
Comment 12 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-18 04:17:02 UTC
You can follow updates on estimated timelines for "Cycle 6 – Service Release 1" on the Release Blog [1].

[1] https://releases.xamarin.com/

The latest blog post for "Cycle 6 – Service Release 1" has an estimate of "Mid-Late January 2016" as the tentative Stable date [2].

[2] https://releases.xamarin.com/alpha-preview-cycle-6-service-release-1/
Comment 13 Dimitar Dobrev 2016-01-30 16:27:43 UTC
I can see "Cycle 6 – Service Release 1" has been published, does it contain this fix?
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2016-01-31 05:33:22 UTC
Yes, Xamarin.Android (e98e962) contains the candidate fix.
Comment 15 Evgeniy Zverev 2016-03-21 18:22:58 UTC
Tested against Xamarin.Android (e98e962) today. The bug transformed into something more fierce and frightening.

Just try the same repro and you end up with no exception and NO DATA.

The result of serialization looks something like this:

<ArrayOfKeyValueOfstringstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><KeyValueOfstringstring/><KeyValueOfstringstring/><KeyValueOfstringstring/></ArrayOfKeyValueOfstringstring>

and should look something like this:

<ArrayOfKeyValueOfstringstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><KeyValueOfstringstring><Key>a</Key><Value>aa</Value></KeyValueOfstringstring><KeyValueOfstringstring><Key>b</Key><Value>bb</Value></KeyValueOfstringstring><KeyValueOfstringstring><Key>c</Key><Value>cc</Value></KeyValueOfstringstring></ArrayOfKeyValueOfstringstring>

It saves the dictionary without Keys and Values i.e. strips your data completely and silently. Makes me shiver in misery and dismay. Argh.

Again. The bug IS NOT fixed, it is now much worse.