What I want to do is to get out a connectionstring through configration manager.
public Database( string connectionName ) {
try {
connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
} catch (ArgumentException exeption) {
throw new ArgumentException("No connection name like this", connectionName, exeption);
}
}
and I am getting:
Object reference not set to an instance of an object.
Yes, of course, because there is no connection string like that, I misspelled.
This is why I've tried to wrap it with a try / catch.
But I've got a Server error, not the exception.
How can I handle, if there is no connection string in the configuration file like connectionName
.