When attempting to utilize app.config in a .Net Core application, you may encounter exceptions such as "Error Initializing the configuration system" and "Could not load type 'System.Configuration.InternalConfigurationHost'." These errors originate from the absence of an implementation for the 'get_bundled_machine_config' method in the 'CoreCompat.System.Configuration' assembly.
Despite installing the 'CoreCompat.System.Configuration' package via NuGet, the issue persists. The following steps provide a solution to this problem:
<!-- START: This is a buildtime work around for https://github.com/dotnet/corefx/issues/22101 -- --> <Target Name="CopyCustomContent" AfterTargets="AfterBuild"> <Copy SourceFiles="App.config" DestinationFiles="$(OutDir)\testhost.dll.config" /> </Target> <!-- END: This is a buildtime work around for https://github.com/dotnet/corefx/issues/22101 -- -->
The above is the detailed content of Why Doesn't My .NET Core App Recognize app.config, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!