Context: I'm currently trying to determine if it'd be possible for my company to create a new web project using the .net-core-2.0 framework that calls some shared class libraries running on .net-framework-4.5 without having to alter them at all.
- I have a
.net framework 4.5shared class library that contains aFoomethod - The
Foomethod makes a call toConfigurationManager.ConnectionStrings - In my
.net-core-2.0web app's controller I callSharedLibrary.Foo() - The
ConfigurationManagerreturnsnull
appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
// Real values replaced with **** for security reasons, of course :-)
"ConnectionStringSecurehSQL": "Data Source=****;Initial Catalog=****;user=****;password=****;Connect Timeout=100000"
}
}
The call to ConfigurationManager
var conn = ConfigurationManager.ConnectionStrings["ConnectionStringSecurehSQL"];
I expected to obtain a connexion string, not a null value. Is what I'm trying to achieve even possible ? If it is what am I doing wrong ?