difference between Settings.settings and web.config or app.config?

For a web application, you would use web.config. For either an EXE or class
library DLL, you would use the "app".config. The difference with the
connection string name is so that you can maintain uniqueness among multiple
config files. Also, the web.config can be accessed from either
System.Configuration.ConfigurationManager or
System.Web.Configuration.WebConfigurationManager


....................................................................................................................................

When I add a connection string by wizard in a WebApp , the wizard add the
connection string to web.config like
<add name="MyDataBase" connectionString="Data Source=.\SQLEXPRESS;Initial
Catalog=xxxx;.....

But if I add the same connection string by wizard in a class library
project, the connection string in app.config will be:
<add name="dataHealth.Properties.Settings.MyDataBase"
connectionString="Data Source=.\SLEEPERS;Initial Catalog=xxxx...

The connection string name in app.config will be initial with
"ProjectName..Properties.Settings"
Why have the difference between web.config and app.config
.............................................................................................................................................




For a web application, you would use web.config. For either an EXE or class
library DLL, you would use the "app".config. The difference with the
connection string name is so that you can maintain uniqueness among multiple
config files. Also, the web.config can be accessed from either
System.Configuration.ConfigurationManager or
System.Web.Configuration.WebConfigurationManager.

I'm not sure if this is what you're looking for.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"ad" <flying@wfes.tcc.edu.tw> wrote in message
news:u$aYi5mUGHA.2444@TK2MSFTNGP14.phx.gbl...[color=blue]
> When I add a connection string by wizard in a WebApp , the wizard add the
> connection string to web.config like
> <add name="MyDataBase" connectionString="Data Source=.\SQLEXPRESS;Initial
> Catalog=xxxx;.....
>
> But if I add the same connection string by wizard in a class library
> project, the connection string in app.config will be:
> <add name="dataHealth.Properties.Settings.MyDataBase"
> connectionString="Data Source=.\SLEEPERS;Initial Catalog=xxxx...
>
> The connection string name in app.config will be initial with
> "ProjectName..Properties.Settings"
> Why have the difference between web.config and app.config









0 comments:

Post a Comment