Setup Help .Net

I am really confused by various configuration options .Net configuration of dll, ASP.net websites, etc. in .Net v2 — especially when considering the impact of a configuration file on the end user end user interface.

So, for example, some of the applications that I work with use the settings we refer to:

string blah = AppLib.Properties.Settings.Default.TemplatePath;

Now this parameter seems cool, because the members are heavily typed, and I cannot type the name of a property that is not in the Visual Studio 2005 IDE. As a result, we get the following lines in App.Config for the executable command line project:

  <connectionStrings>
      <add name="AppConnectionString" connectionString="XXXX" />
      <add name="AppLib.Properties.Settings.AppConnectionString" connectionString="XXXX" />
  </connectionStrings>

(If we do not have the second parameter, someone who released the debugging DLL in the live box could build a debugging connection string built into it - eek)

We also have settings that can be obtained as follows:

string blah = System.Configuration.ConfigurationManager.AppSettings["TemplatePath_PDF"];

Now they look cool, because we can access the settings from the dll code or exe / aspx code, and all we need in the Web or App.config is:

  <appSettings>
    <add key="TemplatePath_PDF" value="xxx"/>
  </appSettings>

However, the course value cannot be set in the configuration files, or the line name may be erroneous, and therefore we have a different set of problems.

So ... if my understanding is correct, the first methods give a strong typing, but a poor sharing of values ​​between dll and other projects. The latter provides better sharing, but weaker typing.

, - . , , - . , , ... , , , !

+5
5

, . , WinForms. - . , App.config , . , ( ) .

.NET. ( , , , app.config .

. -. , web.config . , , " ", , . , , . , .

- . , . , . Intellisense , db ( : ).

:)

+2

VS 2005+, intellisense, , .

string phoneNum = Properties.Settings.Default.EmergencyPhoneNumber;

App.Config.

appSettings ConfigurationElementCollection, ConfigurationElement ConfigurationSection.

, , , : . , , App.Config . , , . App.Config /.

+3

, - , - , .NET. Configurationmanager .

0

, . , , app.config , , .

( ) . . , , , , .

0

- , / . Rob descibes - - 5 6 - , . , Web App.config , / DLL .

- , , ? , , , , web.config ... , ... , "".

0
source

All Articles