B
bz
Hi,
I have a library project that implements a Business Layer for a web
and a desktop application
All my business classes are in this lib, so I have here the connection
string to database as app setting (in app.config
The section in app.config looks like this
<applicationSettings>
<BB.InsuranceService.Lib.Properties.Settings>
<setting name="BBAssurConnString" serializeAs="String">
<value>Data Source=.\SQLEXPRESS;Initial
Catalog=MyDB;Integrated Security=True</value>
</setting>
</BB.InsuranceService.Lib.Properties.Settings>
</applicationSettings>
App.config belongs to project name BB.InsuranceService.Lib
I have a utility class with a Static member which should return the
Connection string, to use it in constuctors of BO, as below
namespace BB.InsuranceService
{
class DBUtility
{
public static string ConnectionString()
{
return
ConfigurationSettings.AppSettings.Get("BBAssurConnString");
}
But I have two problems:
First, I get the following warning:
Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is
obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!
System.Configuration.ConfigurationManager.AppSettings...
But I cannot find ConfigurationManager, it is not in
System.Configuration. Where is this?
And the second problem is (and this is a problem), the call to
ConfigurationSettings.AppSettings.Get("BBAssurConnString"); returns
null.
I have the app.config in the same folder as the library project.
And as I mentioned, this library is used by two projects, a web and
and win forms project. Web app has its own web.config (without any
connection string setting) and Win forms project also has its own
app.config file (also without any connection string setting)
Can anyone help me with this, please?
Thanks,
Bogdan
I have a library project that implements a Business Layer for a web
and a desktop application
All my business classes are in this lib, so I have here the connection
string to database as app setting (in app.config
The section in app.config looks like this
<applicationSettings>
<BB.InsuranceService.Lib.Properties.Settings>
<setting name="BBAssurConnString" serializeAs="String">
<value>Data Source=.\SQLEXPRESS;Initial
Catalog=MyDB;Integrated Security=True</value>
</setting>
</BB.InsuranceService.Lib.Properties.Settings>
</applicationSettings>
App.config belongs to project name BB.InsuranceService.Lib
I have a utility class with a Static member which should return the
Connection string, to use it in constuctors of BO, as below
namespace BB.InsuranceService
{
class DBUtility
{
public static string ConnectionString()
{
return
ConfigurationSettings.AppSettings.Get("BBAssurConnString");
}
But I have two problems:
First, I get the following warning:
Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is
obsolete: 'This method is obsolete, it has been replaced by
System.Configuration!
System.Configuration.ConfigurationManager.AppSettings...
But I cannot find ConfigurationManager, it is not in
System.Configuration. Where is this?
And the second problem is (and this is a problem), the call to
ConfigurationSettings.AppSettings.Get("BBAssurConnString"); returns
null.
I have the app.config in the same folder as the library project.
And as I mentioned, this library is used by two projects, a web and
and win forms project. Web app has its own web.config (without any
connection string setting) and Win forms project also has its own
app.config file (also without any connection string setting)
Can anyone help me with this, please?
Thanks,
Bogdan