简体   繁体   中英

FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager,

I am trying to connect to oracle database from .net core 3.1 using ado.net here's my code

private OracleConnection GetOracleConnection()
{
            string conString = "Data Source=Q550.adr.XXXX.com;Persist Security,Info=True;User ID=XXXX;Password=CCC39";
            OracleConnection con = new OracleConnection(conString);
            return con;
}

but when this function executes following exception occured at line number 2

System.TypeInitializationException: 'The type initializer for 'OracleInternal.Common.ProviderConfig' threw an exception

FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. **

Can anyone tell me what's happening??

You can Install System.Configuration.ConfigurationManager from Nuget

Install-Package System.Configuration.ConfigurationManager

This problem is a known issue as you can see here and the recommended solution is nuget package

https://github.com/pusher/pusher-websocket-dotnet/issues/34

I tried adding a reference to NuGet package System.Configuration.ConfigurationManager, but the latest version of this library (7.0) doesn't contain the ConfigurationManager anymore. So then it still doesn't compile. After a lot of seaching, I figured out I had to include version 4.5 of the NuGet package.

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