Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

BuildConfiguration .Net api compatibility level

Discussion in 'Experimental Scripting Previews' started by Rekart, Feb 8, 2022.

  1. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    22
    Hi. Is there any way to set api compatibility level to .Net 4.x when using build configurations?

    We use GameLift SDK which by default requires .Net 4.x. Our project also uses DOTS, so we have to use build configurations according to documentation. It seems that builds made this way have api copmatibility level set to .Net 2.0 by default, so I'm getting errors at runtime from GameLift dll's. I could reproduce same error with old build routine (File->BuildSettings->Build) if api compatibility level is set to .Net 2.0

    Fortunately, old build routine works for us for now, so we still can make builds for linux game server
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    The Api Compatibility Level should only impact the .NET API surface available at compile time. It has no impact on the .NET base class library used at run time, so I don't think it will have an impact on this behavior. But can you share the errors you see at run time? Maybe that will help us understand their cause.
     
  3. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    22
    I'm getting the following exception:

    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    log4net:ERROR Exception while reading ConfigurationSettings. Check your .config file is well formed XML.
    System.PlatformNotSupportedException: Operation is not supported on this platform.
    at log4net.Util.SystemInfo.GetAppSetting (System.String key) [0x00002] in <9ea670cdbf41450aa8beb1f63c6429db>:0

    If I'm understanding this correctly, log4net is trying to identify actual platform settings, which are not valid in my case for some reason.

    I guess I'll have to dig into log4net source code. Exception is thrown from the following function, by the way

    Code (CSharp):
    1. /// <summary>Lookup an application setting</summary>
    2. /// <param name="key">the application settings key to lookup</param>
    3. /// <returns>the value for the key, or <c>null</c></returns>
    4. /// <remarks>
    5. /// <para>
    6. /// Configuration APIs are not supported under the Compact Framework
    7. /// </para>
    8. /// </remarks>
    9. public static string GetAppSetting(string key)
    10. {
    11.   try
    12.   {
    13.     return ConfigurationManager.AppSettings[key];
    14.   }
    15.   catch (Exception ex)
    16.   {
    17.     LogLog.Error(SystemInfo.declaringType, "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
    18.   }
    19.   return (string) null;
    20. }
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Are you using the the IL2CPP scripting backend now? It does not support System.Configuration.Configuration manager, so that might be the issue.
     
  5. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    22
    Just checked to be sure, I log some system information at startup, including
    Code (CSharp):
    1. System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription

    and get the following:

    Mono 5.11.0 ((no/9283a23)

    So it is Mono
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I'm not sure what is happening then. System.Configuration.ConfigurationManager should work with Mono. Can you submit a bug report?
     
  7. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    22
    Done. ticket id 1403002
     
    JoshPeterson likes this.