Bug 21974 - Using DataContractSerializer with IDictionary with Object Value
Summary: Using DataContractSerializer with IDictionary with Object Value
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.16.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-08-09 05:30 UTC by Klaus Stefan Gerber
Modified: 2017-06-27 19:15 UTC (History)
3 users (show)

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

Sample project and log files (81.54 KB, application/x-rar-compressed)
2014-10-30 11:32 UTC, Abdullah Ali

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 Klaus Stefan Gerber 2014-08-09 05:30:22 UTC
When serializing a class containing a Dictionary with a key or value of type Object the application crashes:

Having a class DummyObject with the following property:

public IDictionary<String, Object> Values { get; set; }

Then this line: 

DataContractSerializer serializer = new DataContractSerializer(typeof(DummyObject));

Will throw the following exception:

"'this' type cannot be an interface itself"

"  at System.Type.GetInterfaceMap (System.Type interfaceType) [0x00000] in <filename unknown>:0 \n  at…"

The strange thing is that Object can be used in other situations, the following wouldn't throw an error:

public Dictionary<String, Object> Values { get; set; }

public IList<Object> Values { get; set; }

public Object Values { get; set; }
Comment 1 Prashant manu 2014-08-26 06:40:47 UTC
Could you please provide us the test steps you followed. If possible please
attach a small complete project that demonstrates this behavior.

Also can you please add the logs from the following places?:
On XS IDE Log  Location: XS>Help> Open Log Directory> IDE.log file (with latest
AndroidTools log: XS->Help->Open Log Directory->AndroidTools.log

If using VS, 
IDE log: Location: C:\User\AppData\Local\Xamarin\Log\ 
(Devenev file with latest timestamp)
Android Trace log: Location: \AppData\Local\Xamarin\Log\XamarinAndroid
Comment 2 Abdullah Ali 2014-10-30 11:32:50 UTC
Created attachment 8561 [details]
Sample project and log files

Attached is a sample project, in which I recreated the issue. I have also attached the log files as requested.
Comment 3 Chris Hardy [MSFT] 2017-06-27 19:15:33 UTC
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue.