嘗試在 .Net Core 應用程式中使用 app.config時,您可能會遇到諸如「Error正在初始化設定係統」和「無法載入類型「System.Configuration.InternalConfigurationHost」。」這些錯誤源自於「CoreCompat.System.Configuration」程式集中缺少「get_bundled_machine_config」方法的實作。
儘管透過 NuGet 安裝了「CoreCompat.System.Configuration」包,問題仍然存在。以下步驟提供了此問題的解決方案:
<!-- 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 -- -->
以上是為什麼我的 .NET Core 應用程式無法識別 app.config,如何修復它?的詳細內容。更多資訊請關注PHP中文網其他相關文章!