Search Unity

Issue with System.Configuration.ConfigurationManager::get_AppSettings on iOS

Discussion in 'iOS and tvOS' started by kergalert, Dec 23, 2020.

  1. kergalert

    kergalert

    Joined:
    Feb 1, 2019
    Posts:
    3
    I am having a persistent issue in building my Unity (version 2020.2.0a15) game, which utilizes AWS Gamelift, on iOS. It runs fine on simulator, and I can build and successfully run on my mac with all of my networking, matchmaking, etc. working.

    However, when I try to build this to my iOS device through xcode (12.3), I get the error below, which seems related to IL2CPP based on my search so far.

    The final line of the stack trace is: System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings. I've copied the full logging below.

    I have spent a few days trying to fix this myself, but have been unable to make progress. The common issues referenced during my search have been:
    • link.xml not being set up, so the code gets stripped. I have one, posting below
    • AWS config not being set up. I have one, posting below
    • log4net not being configured. On my local version, I have a log4net.xml set up, which is being read and I confirmed the appender is working and logging to a file on my dev pc when I run in the simulator
    • Needing to use 2.0 instead of 4.x - I've tried building with 2.0 as much as possible (e.g. using log4net 2.0, and all the necessary dependencies), and again it works in editor but fails when built to an iphone.
    • AWS being fundamentally incompatible with Il2CPP (which I hope isn’t true, and seems wrong if there are gamelift games on ios?)
    Could somebody please help me figure out how to fix this and get gamelift working on mobile builds from unity? I've even tried setting logging to None in AWS settings, but to no avail.


    References:

    Full stack trace from xcode debug window; this is triggered when I instantiate my gamelift client from my networkmanager class.

    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.LogLog…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetVersionInfo () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.LogLog…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetVersionInfo () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.LogLog…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetVersionInfo () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetVersionInfo () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetVersionInfo () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager…cctor () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.NotSupportedException: System.Configuration.ConfigurationManager::get_AppSettings
    at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.DefaultRepositorySelector.ConfigureRepository (System.Reflection.Assembly assembly, log4net.Repository.ILoggerRepository repository) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.DefaultRepositorySelector.CreateRepository (System.Reflection.Assembly repositoryAssembly, System.Type repositoryType, System.String repositoryName, System.Boolean readAssemblyAttributes) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.DefaultRepositorySelector.CreateRepository (System.Reflection.Assembly repositoryAssembly, System.Type repositoryType) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.DefaultRepositorySelector.GetRepository (System.Reflection.Assembly repositoryAssembly) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.Core.LoggerManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Reflection.Assembly repositoryAssembly, System.String name) [0x00000] in <00000000000000000000000000000000>:0
    at log4net.LogManager.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Controller…cctor () [0x00000] in <00000000000000000000000000000000>:0
    2020-12-22 11:33:18.190362-0800 TSBRV2[26335:3201119] Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x1181a4a50>.
    UnloadTime: 2.203000 ms
    False
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Controller:Start()

    Ignore me - called to open Console
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogError(Object)
    Controller:Start()

    ArgumentNullException: Value cannot be null.
    Parameter name: obj
    at System.Threading.Monitor.ReliableEnterTimeout (System.Object obj, System.Int32 timeout, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.Monitor.ReliableEnter (System.Object obj, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.Monitor.Enter (System.Object obj, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.AWSConfigs.TraceListeners (System.String source) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.TraceSourceUtil.GetTraceSourceWithListeners (System.String name, System.Diagnostics.SourceLevels sourceLevels) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.TraceSourceUtil.GetTraceSource (System.Type targetType, System.Diagnostics.SourceLevels sourceLevels) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.TraceSourceUtil.GetTraceSource (System.Type targetType) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.InternalSystemDiagnosticsLogger…ctor (System.Type declaringType) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.Logger.GetHashCode () [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.Internal.Util.Logger.GetLogger (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
    at Amazon.Runtime.CredentialManagement.SharedCredentialsFile…ctor () [0x00000] in <00000000000000000000000000000000>:0
    at GameLiftClient.CreateGameLiftClient () [0x00000] in <00000000000000000000000000000000>:0
    at GameLiftClient…ctor () [0x00000] in <00000000000000000000000000000000>:0
    at NetworkManager…ctor () [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.GameObject.AddComponent (System.Type componentType) [0x00000] in <00000000000000000000000000000000>:0
    at UnityEngine.GameObject.AddComponent[T] () [0x00000] in <00000000000000000000000000000000>:0
    at Controller.Start () [0x00000] in <00000000000000000000000000000000>:0
    UnityEngine.GameObject:AddComponent(Type)
    UnityEngine.GameObject:AddComponent()
    Controller:Start()


    My log4net.xml file, in my Assets folder, though I have since moved this configuration to be in code so I can have a dynamic log path for my mac build.


    <?xml version="1.0" encoding="utf-8"?>

    <log4net>
    <appender name="EventLog" type="log4net.Appender.RollingFileAppender">
    <file value="./TestLog/tsbrlog.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Once" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="1MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date %-5level in [%thread] %logger%newline%message%newline" />
    </layout>
    </appender>
    <root>
    <level value="DEBUG" />
    <appender-ref ref="EventLog" />
    </root>
    </log4net>


    My awsconfig.xml, in Assets/Resources:

    <?xml version="1.0" encoding="utf-8"?>
    <aws correctForClockSkew="true" region="us-west-2">
    <logging logTo="None"
    logResponses="Always"
    logMetrics="false"
    logResponses="Never"
    logMetricsFormat="JSON" />
    <s3 useSignatureVersion4="true" />
    </aws>


    My (Very permissive) link.xml -- note I also turned off code stripping in project settings.


    <linker>
    <assembly fullname="UnityEngine">
    <type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" />
    <type fullname="UnityEngine.Networking.UploadHandlerRaw" preserve="all" />
    <type fullname="UnityEngine.Networking.UploadHandler" preserve="all" />
    <type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" />
    <type fullname="UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" />
    </assembly>
    <assembly fullname="AWSSDK.Core" preserve="all"/>
    <assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
    <assembly fullname="AWSSDK.GameLift" preserve="all"/>
    <assembly fullname="AWSSDK.SimpleNotificationService" preserve="all"/>
    <assembly fullname="Microsoft.Bcl.AsyncInterfaces" preserve="all"/>
    <assembly fullname="Newtonsoft.Json" preserve="all"/>
    <assembly fullname="System.Buffers" preserve="all"/>
    <assembly fullname="System.Configure" preserve="all"/>
    <assembly fullname="System.Configuration" preserve="all"/>
    <assembly fullname="System.Configuration.Install" preserve="all"/>
    <assembly fullname="System.Object" preserve="all"/>
    <assembly fullname="System.Numeric.Vectors" preserve="all"/>
    <assembly fullname="System.Runtime.CompilerServices.Unsafe" preserve="all"/>
    <assembly fullname="System.Text.Encodings.WEb" preserve="all"/>
    <assembly fullname="System.Threading.Tasks.Extensions" preserve="all"/>
    <assembly fullname="System.ValueTuple" preserve="all"/>
    <assembly fullname="Google.Protobuf" preserve="all"/>
    <assembly fullname="log4net" preserve="all"/>
    <assembly fullname="System.Configuration" preserve="all"/>
    <assembly fullname="mscorlib">
    <namespace fullname="System.Security.Cryptography" preserve="all"/>
    </assembly>
    <assembly fullname="System">
    <namespace fullname="System.Security.Cryptography" preserve="all"/>
    </assembly>
    <assembly fullname="AWSSDK.CognitoIdentity" preserve="all"/>
    <assembly fullname="AWSSDK.SecurityToken" preserve="all"/>
     
  2. kergalert

    kergalert

    Joined:
    Feb 1, 2019
    Posts:
    3
    Hey Pip, just following up on this thread. I got this working (on iOS) by switching to AWS 2.0 SDKs from the zip in this documentation page: https://aws.amazon.com/blogs/develo...r-net-standard-2-0-from-unity-xamarin-or-uwp/

    I had to make some code changes (have to use async functions for many network calls, but that should be moved to lambda once I’m done with my proof of concept anyways).

    I used the libraries from the realtime package as they were, I think, as they only build the one version. After this my game works and I can call matchmaking & query my dynamodb on both my editor, mac builds, and ios builds.

    Unfortunately, now I am running into issues with TLS not working on ios builds, but as far as this specific error it’s resolved for me
     
  3. ManisharanS

    ManisharanS

    Joined:
    Apr 19, 2019
    Posts:
    1
    yes it worked by switching to 2.0 dlls. Thanks @kergalert
     
  4. nadunliyanage

    nadunliyanage

    Joined:
    Feb 16, 2021
    Posts:
    2
    Hi, this is quite an old thread but fixed a similar issue with the suggested approach. Now I'm getting an exception as

    ArgumentNullException: Value cannot be null.
    Parameter name: stream
    at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean leaveOpen) [0x00000] in <00000000000000000000000000000000>:0


    This is coming at
    new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(), region);


    Do you have any suggestions?
     
  5. jalajshah

    jalajshah

    Joined:
    Mar 5, 2018
    Posts:
    62
    Hey guys,

    I solved this System.Configuration error by switching to .NET Standard 2.0 DLLs but I ran into new error, which I'm not sure what's going on.

    So basically error is about mscorlib. I'm posting screenshots to check.

    Unity version: 2020.3.26f1 LTS
    Platform: Want to target both Android and iOS but this error also occurs in Editor as well.
    Scripting Backend: IL2CPP
    API Compatibility Level: .NET Standard 2.0
    Target Architecture: ARM64

    Thank you :)

    upload_2022-3-10_18-7-23.png upload_2022-3-10_18-7-37.png upload_2022-3-10_18-7-51.png
     
  6. amit_justplay

    amit_justplay

    Joined:
    Dec 27, 2020
    Posts:
    2