Bug 29917 - DataContractSerializer throws when created with DataContractSerializerSettings.
Summary: DataContractSerializer throws when created with DataContractSerializerSettings.
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-10 13:16 UTC by sornakumar
Modified: 2015-12-24 15:36 UTC (History)
4 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 GitHub or Developer Community 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 sornakumar 2015-05-10 13:16:20 UTC
When I create a new DataContractSerializer as follows:
new DataContractSerializer(typeof(DummyClass), new DataContractSerializerSettings());

The following error is thrown:
System.ArgumentNullException: Value cannot be null.
Parameter name: rootName
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes) <0x6b8200 + 0x0012b> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes, Int32 maxObjectsInGraph, Boolean ignoreExtensionDataObject, Boolean preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) <0x6b8178 + 0x0002f> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes, Int32 maxObjectsInGraph, Boolean ignoreExtensionDataObject, Boolean preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, System.Runtime.Serialization.DataContractResolver dataContractResolver) <0x6b80f8 + 0x0004b> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Runtime.Serialization.DataContractSerializerSettings settings) <0x6b8058 + 0x00083> in <filename unknown>:0 
  at SimpleXMLReader.Program.Main () <0x6b7ec0 + 0x0004b> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: rootName
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes) <0x6b8200 + 0x0012b> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes, Int32 maxObjectsInGraph, Boolean ignoreExtensionDataObject, Boolean preserveObjectReferences, IDataContractSurrogate dataContractSurrogate) <0x6b8178 + 0x0002f> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, IEnumerable`1 knownTypes, Int32 maxObjectsInGraph, Boolean ignoreExtensionDataObject, Boolean preserveObjectReferences, IDataContractSurrogate dataContractSurrogate, System.Runtime.Serialization.DataContractResolver dataContractResolver) <0x6b80f8 + 0x0004b> in <filename unknown>:0 
  at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, System.Runtime.Serialization.DataContractSerializerSettings settings) <0x6b8058 + 0x00083> in <filename unknown>:0 
  at SimpleXMLReader.Program.Main () <0x6b7ec0 + 0x0004b> in <filename unknown>:0 

Using Mono version - Mono JIT compiler version 4.1.0 (master/af7ab54 Fri Apr 17 10:08:44 PDT 2015)
Comment 1 Miguel de Icaza [MSFT] 2015-12-24 15:36:28 UTC
This issue is no longer present, as we upgraded our class libraries:

mono$ csharp -r:System.Runtime.Serialization
Mono C# Shell, type "help;" for help

Enter statements below.
csharp> class X { public int Foo; }
csharp> new System.Runtime.Serialization.DataContractSerializer(typeof(X), new System.Runtime.Serialization.DataContractSerializerSettings());   
System.Runtime.Serialization.DataContractSerializer
csharp>