Elegabalus
Programmer
I've got a class library that I use as the data access component of a web application in .NET 2.0.
I'm having trouble getting the connectionString information from the file, though.
When I hard code the connectionString into a string, it works fine.
When I try to get the value from the config file, it throws a null reference exception. Essentially, the code isn't getting the value from the config file.
I've added a manual reference to System.Configuration (as many posts on google mention is necessary). The following is the code I'm using to access the connectionString ("test" is the correct name of the key)
Has anyone ever come across this before? I've tried the exact same code in a web application, and it works fine.
Any help is appreciated.
I'm having trouble getting the connectionString information from the file, though.
When I hard code the connectionString into a string, it works fine.
When I try to get the value from the config file, it throws a null reference exception. Essentially, the code isn't getting the value from the config file.
I've added a manual reference to System.Configuration (as many posts on google mention is necessary). The following is the code I'm using to access the connectionString ("test" is the correct name of the key)
Code:
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["test"].ConnectionString;
Has anyone ever come across this before? I've tried the exact same code in a web application, and it works fine.
Any help is appreciated.