netstandard 2.0 does not have AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

According to this article, which I found when looking for replacement for PlatformServices.Default.Application.ApplicationBasePath, it should be either of:

  • AppDomain.CurrentDomain.SetupInformation.ApplicationName
  • Assembly.GetEntryAssembly().GetName().Name

Just like you, I've just found out that the first one does not exist in recent 2.0 so I'll be using the GetEntryAssembly name..

..however keep in mind that GetEntryAssembly may be null when used i.e. from within a test runner like xUnit, or probably will be wrong if your appcode is ran from another not-yours hosting/startup module, etc - so that is not a perfect replacement.


Add the ConfigurationManager as a NuGet

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
  <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>

Use ConfigurationManager in C#

var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Log4NetLogger.Configure(configFile.FilePath);