app-config

NameValueSectionHandler - can i use this section type for writing back to the application config file?

匆匆过客 提交于 2019-12-20 04:52:08
问题 back to the topic of why didn't .net provide a simple (i don't want to implement "ConfigurationSection" "ConfigurationElement" "ConfigurationProperty" for 2 values) way to write values back into application config files... (and i don't want to use 'user' app config) i want to write to the app.config values, i tired the above method of key,value - for reading its fine but i can't write back into it (it says the collection is read only). even though the following method is supplied -

NameValueSectionHandler - can i use this section type for writing back to the application config file?

你说的曾经没有我的故事 提交于 2019-12-20 04:51:09
问题 back to the topic of why didn't .net provide a simple (i don't want to implement "ConfigurationSection" "ConfigurationElement" "ConfigurationProperty" for 2 values) way to write values back into application config files... (and i don't want to use 'user' app config) i want to write to the app.config values, i tired the above method of key,value - for reading its fine but i can't write back into it (it says the collection is read only). even though the following method is supplied -

Accessing app.config in ASP.NET

北城以北 提交于 2019-12-20 01:08:52
问题 I am using app.config file to read data from it.. I am loading the app.config file as: string app_path = HttpContext.Current.Server.MapPath("app.config"); xmlDoc.Load(app_path); string image_path = ConfigurationManager.AppSettings["Test1"]; and i want to get the value of "Test1". But the value of test1 is comming "null".. how can i get the value of "test1" from app.config file.. i created the app.config file as: <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key=

Persisting the data in app.config between debugging sessions

这一生的挚爱 提交于 2019-12-19 18:27:25
问题 So, long story short, I'm developing an application that will make use of some configuration info that may be changed at runtime through the application itself. For the purpose I've thought of using the Settings class. The problem, thought, is that information is not persisted between different runs of the application: Run 1) Console.WriteLine(Settings.Default["User"]); //prints "Default user" Settings.Default["User"] = "abc"; Console.WriteLine(Settings.Default["User"]); //prints "abc" Run 2)

What steps do I need to take to convert from a class library to a WCF?

我们两清 提交于 2019-12-19 17:43:13
问题 I created a project as a Class Library. Now I need to make it into a WCF. I can create a WCF project, but I would like to avoid all that fuss with TFS. I've done the App.config and added the /client:"wcfTestClient.exe" line to the Command line arguments. But there seems to be something else missing from it launching the Hosting. 回答1: I discovered the following doing the opposite to what you are trying to achieve, i.e. changing a service library to a console application.. some of the settings

C# App.config vs Settings File

旧时模样 提交于 2019-12-19 12:24:52
问题 This may sound like a trivial question, however I have looked over the web briefly and what I found was that app.config is basically an older mechanism for storing Application key/pairs of data for the application. What I want to know is there any reason we (as .NET developers) would opt to use app.config over a Settings file ? -Can someone please provide some pros and cons on both so we can use them properly. thanks again 回答1: App.config for desktop applications and Web.config for web

How to create custom config section in app.config

早过忘川 提交于 2019-12-19 10:30:42
问题 I want to add the custom configsection in the app.config file as follows <Companies> <Company name="" code=""/> <Company name="" code=""/> </Companies> <Employees> <Employee name="" Des="" addr="" sal=""/> <Employee name="" Des="" addr="" sal=""/> </Employeess> <Departments> <Department Id="" Projects=""/> </Departments> <Projects> <Project Path=""/> </Projects> In the Department section it is referring to Projects section. Can anybody tell me way to do it? And how to access it in my code?

Is the bindingRedirect .config file needed or all assemblies in an application? [duplicate]

青春壹個敷衍的年華 提交于 2019-12-19 10:26:22
问题 This question already has answers here : Why NuGet adds app.config with assemblyBinding to LIBRARY projects during a NuGet package update? (3 answers) Closed 4 years ago . Using NuGet to install the Microsoft.Bcl.Async package for a solution that has several dlls and just one exe, which uses all other dlls, NuGet automatically creates a .config file (or adds to an existing one) for every single project the Bcl package is added to. In practice I end up with > 20 config files all containing the

.NET 2.0 App.Config connection strings includes unwanted SQLExpress default

馋奶兔 提交于 2019-12-19 09:27:04
问题 I'm using a connectionStrings section within an app.config file in a .NET 2.0 project. The config section contains two connection strings I have defined. When I retrieve the ConnectionStringSettingsCollection it has a count of 3. The 0th entry is a connection to SQLExpress Name: LocalSqlServer, ConnectionString: data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true Why is this connection being included even though it's not in my app

How can i update app.config connectionstring Datasource value in C#?

喜夏-厌秋 提交于 2019-12-19 08:57:34
问题 Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.ConnectionStrings.ConnectionStrings["MyConnectionString",String.Format("DataSource={0};")].ConnectionString=textBox1.Text; config.Save(ConfigurationSaveMode.Modified, true); ConfigurationManager.RefreshSection("connectionStrings"); I'm having trouble at line two. I cant seem to get the syntax correct. As you can see, i only want to update the DataSource value only. For example, if current