1

Topic: How a configuration file to select?

The code like using System. Configuration;... class Program {static string appconfigfile = "myprogram.exe.config"; static Configuration config = ConfigurationManager.OpenExeConfiguration (appconfigfile); static string server = config. AppSettings ["ServerName"]; does not work, a call config. AppSettings it is impossible because of the Error 1 "System.Configuration.ConfigurationElement.this [string]" it is inaccessible because of its protection level Simply I want to transfer in command line in options file name of a configuration and to work with it also as before was ConfigurationManager. AppSettings, etc. In msdn anything such, it is written "Opens the specified file of a configuration of the client as object Configuration." About method OpenExeConfiguration

2

Re: How a configuration file to select?

Hello, Michael7, you wrote: M> does not work, a call config. AppSettings it is impossible because of config. AppSettings. Settings. , a dark heritage of the first . Only consider that appconfig - an excellent method  the arbitrary code in your process, for example, through <configSections> <section name = "BadSection" type = "BadType, BadAssembly"/> </configSections> <BadSection SomeProperty=1/> Not, in most cases it from those methods the attacks which Rejmond Chen softly names doubtful. At first, it is necessary to allocate any miracle the assembly so that it saw application. Secondly, application should sort out explicitly config. Sections or to address to BadSection by name. But the nobility about such moment all the same is better,  not to know.