Whenever I add dataset in my class library project using the wizard it gives me an option to save the connection string in app.config file and after selecting the option it do save the string in file but when I check the dataset designer it always saves it in project property object:
private void InitConnection() {
this._connection = new global::System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = global::BaseClassLibrary.Properties.Settings.Default.DBConnectionString;
}
and this is not so useful because when I try to use this project dll and override the connection string by writing it in web.config or app.config … it doesn’t refer to it …
and one interesting fact that if you follow the same process of adding dataset using wizard in web project then it actually refer web.config for connection string … which is a bit strange … and in web project dataset don’t generate designer classes …
Is there anyway I can do the desire action?
The Properties type is a wrapper around application and user-specific settings as described here.
It appears that you are attempting to get the configuration settings from your library assembly (.dll) rather than the configuration settings from the application/site that is referencing your library. I am guessing this based on the fact that you are using this property:
In situations where a referenced assembly needs a configuration setting from the running application/site I usually:
Note that this static type needs to be defined in one of your core libraries because you cannot have a circular reference: App – Library – App.
Hope this helps.