Search Issue Tracker
By Design
Votes
13
Found in
Issue ID
1034782
Regression
No
System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer
Using works fine in editor, but on device (iOS / Android) we are getting the error below. Looks like others have encountered this (https://forum.unity.com/threads/uwp-datacontractserializer-fails-to-load-configuration-section.507801/)
The Error:
[WARNING] System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer.
at System.Runtime.Serialization.Configuration.DataContractSerializerSection.UnsafeGetSection () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.DataContract.get_ConfigSection () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.DataContract.LoadKnownTypesFromConfig (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] typesChecked, System.Collections.Generic.Dictionary`2[System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract]& knownDataContracts) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] typesChecked, System.Collections.Generic.Dictionary`2[System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract]& knownDataContracts) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.ClassDataContract+ClassDataContractCriticalHelper.get_KnownDataContracts () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType (System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlWriterDelegator xmlWriter, System.Object obj, System.RuntimeTypeHandle declaredTypeHandle) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObjectContent (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObject (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.IO.Stream stream, System.Object graph) [0x00000] in <00000000000000000000000000000000>:0
at WBG.Common.Request.WBGRequest.SerializeType[T] (T data) [0x00000] in <00000000000000000000000000000000>:0
at WBG.Common.Request.WBGRequest.Send[SendType,RespType] (System.String url, WBG.Common.Request.WBGRequest+Verb verb, System.Collections.Generic.Dictionary`2[TKey,TValue] headers, SendType data) [0x00000] in <00000000000000000000000000000000>:0
at Iridium.IR_Request.SendRequest[SendType,RespType] (System.String url, WBG.Common.Request.WBGRequest+Verb verb, SendType data) [0x00000] in <00000000000000000000000000000000>:0
at IridiumSDK.SendRequest[SendType,RespType] (System.String url, WBG.Common.Request.WBGRequest+Verb verb, SendType data) [0x00000] in <00000000000000000000000000000000>:0
at IridiumEATService.GetActionTimerEntities (System.String playerId) [0x00000] in <00000000000000000000000000000000>:0
at DreadAPI.DN_EAT.GetActionTimerEntities (System.String playerId) [0x00000] in <00000000000000000000000000000000>:0
at ActionTimerEntityManager.RefreshActionTimersData (WBG.Common.Callbacks+AsynchronousCallbackType callback) [0x00000] in <00000000000000000000000000000000>:0
at WBG.Common.WBGAsync._Next (System.String error, System.Object retval) [0x00000] in <00000000000000000000000000000000>:0
at WBG.Assets.HttpAssetBundleLoader+<DownloadAssetBundleWithCoroutine>c__Iterator0.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
WBG.Logging.Internal.UnityConsoleDescriptor:Write(StringBuilder)
WBG.Logging.Internal.LogManager:WriteToDescriptors(StringBuilder)
IridiumEATService:GetActionTimerEntities(String)
DreadAPI.DN_EAT:GetActionTimerEntities(String)
ActionTimerEntityManager:RefreshActionTimersData(AsynchronousCallbackType)
WBG.Common.WBGAsync:_Next(String, Object)
WBG.Assets.<DownloadAssetBundleWithCoroutine>c__Iterator0:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
-
CatherineIrkalla
Jul 30, 2018 01:17
I notice Severity = 3 "Workaround is possible" any ideas what the workaround might be?
-
CatherineIrkalla
Jul 30, 2018 01:13
More info:
* the same error happens when trying to save files on Android in our application, it isn't limited to loding.
* Our serialization classes are here: https://gitlab.com/youreperfectstudio/StageMechanic/tree/master/StageMechanic/Assets/SaveLoadSupport
* The issue only happens when dealing with file save/load on Android.
* Our "undo" support when playing in the game uses the Binary serializer (in memory) and works just fine - it is either related to dealing with the filesystem or the Json serializer.
-
CatherineIrkalla
Jul 30, 2018 01:06
Hmm I can't seem to edit the post I made earlier but if more info is needed when using our codebase to debug the issue please log onto our Discord server at: https://discord.gg/TBU4MyE
and ping any mod.To load a file in the application simply click Load on the main menu and select a .json file from the .zip I linked in the other post and click the load button on the bottom right - then find error in the Android log.
-
CatherineIrkalla
Jul 30, 2018 00:55
We are having this issue as well using 2018.2 and building on Windows. Loading works perfectly fine on Windows but we are getting the error below on the log when trying to load a file on Android 7 on a Galaxy S7.
Good news: our project is Open Source and relatively straight forward. Here is the GitLab page: https://gitlab.com/youreperfectstudio/StageMechanic
And a recent failed attempt at fixing our Android file loading problems: https://gitlab.com/youreperfectstudio/StageMechanic/commit/4f5d60561a6c67a791cb701d2995109cbb225dc9
Level files to test loading are here: https://drive.google.com/open?id=184WZPbZ-HFTzC4DYRKJgy567AQ1R38Qy
They are just .json files and work without issue on Windows builds.
Android log:
07-29 19:46:55.962: E/Unity(5185): ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer.
07-29 19:46:55.962: E/Unity(5185): at System.Runtime.Serialization.Configuration.DataContractSerializerSection.UnsafeGetSection () [0x00026] in <8c7da264bf14459e96039e847cd62e77>:0
07-29 19:46:55.962: E/Unity(5185): at System.Runtime.Serialization.DataContract.get_ConfigSection () [0x00007] in <8c7da264bf14459e96039e847cd62e77>:0
07-29 19:46:55.962: E/Unity(5185): at System.Runtime.Serialization.DataContract.LoadKnownTypesFromConfig (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] typesChecked, System.Collections.Generic.Dictionary`2[System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract]& knownDataContracts) [0x00000] in <8c7da264bf14459e96039e847cd62e77>:0
07-29 19:46:55.962: E/Unity(5185): at System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] typesChecked, System.Collections.Generic.Dictionary`2[System.Xml.XmlQualifiedName,System.Runtime.Serialization.DataContract]& knownDataContracts) [0x00228] in <8c7da264bf1445 -
yaKashif
Jul 13, 2018 20:34
Any update on this?
Any solution?
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- GPU utilization increases by 20% on Meta Quest headsets when Render Graph is enabled on 6000.0.16f1 and higher
- Value on Slider (Int) control in UI Builder displays as default when saving UI Document
- Color mismatch in UI Builders Library panel when the Editors theme is set to Light Mode
- [Android ] "AndroidJNI.ToBooleanArray" returns a random non-zero value instead of "IntPtr.Zero" when the method argument is null
- Non-HDR color picker opens when selecting material color with HDR enabled
Resolution Note:
Thanks for submitting this issue. I don't think this is a problem on the Unity side, as we do have a good work around for this issue. I've updated the forum thread with details, and I'll include the same details here:
I've seen two different errors in this case, based on the Api Compatibility Level setting.
If the Api Compatibility Level for the project is .NET 4.x, the error originally reported in this thread will occur.
If the Api Compatibility Level for the project is .NET Standard 2.0, I see an exception that starts like this:
NullReferenceException: Object reference not set to an instance of an object.
at System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.TryWritePrimitive (System.Type type, System.Func`1[TResult] value, System.Reflection.MemberInfo memberInfo, System.Nullable`1[T] arrayItemIndex, System.Xml.XmlDictionaryString name, System.Int32 nameIndex) [0x00000] in <00000000000000000000000000000000>:0
If you are using Unity 2018.2 or newer, you can work around this issue by doing the following:
1. Choose the .NET Standard 2.0 Api Compatibility Level
2. Add a link.xml file to the Assets folder of your project with the following contents:
<linker>
<assembly fullname="System.Runtime.Serialization" preserve="all"/>
</linker>
The problem here is that the DataContractJsonSerializer implementation in the class library assembly System.Runtime.Serialization.dll uses reflection to access some methods. The Unity managed code linker strips away these methods, and the DataContractJsonSerializer class fails to work properly. By preserving everything in System.Runtime.Serialization.dll, those methods are kept.
Note that this is a different problem with the .NET 4.x Api Compatibility Level. That one is a little more involved. We've corrected it in 2018.3, which should be public beta soon. Prior to that release, you will need to use the .NET Standard 2.0 Api Compatibility Level to work around this issue. Once 2018.3 is available, the link.xml file provided here will still be necessary to make this work properly with either Api Compatibility Level option.