Cannot add System.Configuration.ConfigurationManager to .NET core application

老子叫甜甜 提交于 2021-01-27 04:35:00

问题


I need this package to access settings in the Web.config:

Restoring packages for D:\ ... path ... \dozor-backend.csproj...
Package System.Configuration.ConfigurationManager 4.4.0 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package System.Configuration.ConfigurationManager 4.4.0 supports:
  - net461 (.NETFramework,Version=v4.6.1)
  - netstandard2.0 (.NETStandard,Version=v2.0)
Package restore failed. Rolling back package changes for 'dozor-backend'.
Time Elapsed: 00:00:01.0720066
========== Finished ==========

I've seen other people use this package in net core app, so what's the issue? How can I use it in .NET Core app?


回答1:


As error said, you can use System.Configuration.ConfigurationManager only starting from .NETCoreApp 2.0. For the previous version, you only have new ASP.NET Core configuration mechanism provided by Configuration API.

Regarding a provided link: reread it carefully, it doesn't say that ConfigurationManager` is available and works with the previous version of .NET Core.



来源:https://stackoverflow.com/questions/46473508/cannot-add-system-configuration-configurationmanager-to-net-core-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!