2

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.5 shared class library that contains a Foo method
  • The Foo method makes a call to ConfigurationManager.ConnectionStrings
  • In my .net-core-2.0 web app's controller I call SharedLibrary.Foo()
  • The ConfigurationManager returns null

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 ?

Mathieu VIALES
  • 4,526
  • 3
  • 31
  • 48

0 Answers0