I have a class library that contains a valid connectionString inside the app.config. Inside that class library I want to use it with
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
My ASP.net 4.0 framework application references that DDL and retrieves data from it. I want create a Entity Framework 4 DataContext within my DDL with the ConnectionString from the App.config. (I do not want to pass the connectionString from my ASP.net application in every single method. (I'm using ObjectDataSources))
However, this line inside my DLL throws a NullReferenceException.
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
How can I fix this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…