简体   繁体   中英

Could not load file or assembly 'System.Configuration.ConfigurationManager'

Below code throw exception :

Could not load file or assembly 'System.Configuration.ConfigurationManager'

private static readonly log4net.ILog log = 
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

在此处输入图像描述

and i tried to install package but it could not在此处输入图像描述

.NET version 4.5.2 Solution explorer , right click References -> Add reference...

In the new window choose Assemblies and fill in "System.configuration" in the search box. Is the checkbox checked? If not, hover over it, select it. 参考经理

.NET version 4.6.1 It could be that you forgot to add the nugget package?

In the solution explorer , right click References , choose Manage Nugget Packages..

如何打开 Nugget 包管理器

Under the Browse , fill in "System.Configuration.ConfigurationManager". Choose the one from Microsoft and see what the tab on the right says. Install if not already installed. Nugget 包管理器概述

A quick update that this may also happen when mixing .net core and .net framework assemblies.

In my case is was a .net framework test project referencing a mixture of .net standard and .net framework projects. Once I moved the test into a .net core test project the code runs fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM