简体   繁体   中英

Could not load file or assembly 'System.Configuration.ConfigurationManager, The system cannot find the file specified

I have a solution with two projects, one in Framework and the other in Core. They interact with one another. But I am getting this error in the Framework project even though I have this Nuget Library installed. I notice that when I delete the older version (System.Configuration) this code will not compile...

ConfigurationManager.ConnectionStrings["NAME"].ConnectionString;

Which tells me that it is ignoring the "System.Configuration.ConfigurationManager" anyway. But if I have both installed it errors out at runtime with the above mentioned error. Why would the Framework project even need this library? It's a Core library no?

I should point out that the Framework project is a class library.

You cannot reference a .NET Framework assembly from a .NET Core assembly (or vice versa).

It might look like it works and it might indeed work for a very small subset of assemblies, but the documentation says you cannot and you will get errors to prove the documentation correct. You just got one of them.

So what is the solution if you want to shared code? Well you could create a .NET Standard assembly. Those can be referenced by both .NET Core and .NET Framework. But if you need one assembly to be .NET Core and the other to be .NET Framework, you are out of luck. You will have to use indirect means of communication (for example HTTP or named pipes or memory mapped files) as if it were two completely different programming languages.

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