app-config

web.config and app.config confusion

不羁岁月 提交于 2019-11-26 08:31:01
问题 I have a DLL that references a web service. The block it has put into the app.config is (I have changed the names but you\'ll get the idea): <applicationSettings> <DLLName.My.MySettings> <setting name=\"DLLName_WebReferenceName_ASMXName\" serializeAs=\"String\"> <value>http://URL/Filename.asmx</value> </setting> </DLLName.My.MySettings> </applicationSettings> My website references this DLL. The question is, what do I add to the web.config to override the above setting (alternativly, do I just

ConfigurationManager doesn&#39;t save settings

心不动则不痛 提交于 2019-11-26 06:46:47
问题 Here is the code I\'m using: private void SaveConfiguration() { if (txtUsername.Text != \"\" && txtPassword.Text != \"\") { ConfigurationManager.AppSettings[\"Username\"] = txtUsername.Text; ConfigurationManager.AppSettings[\"Password\"] = txtPassword.Text; MessageBox.Show(\"Su configuracion guardo exitosamente.\", \"Exito!\"); this.Close(); } else { MessageBox.Show(\"Por favor lleno los campos.\", \"Error.\"); } } Now, the settings are persisted but when I close the application and press F5

Equivalent to &#39;app.config&#39; for a library (DLL)

耗尽温柔 提交于 2019-11-26 06:33:18
Is there an equivalent to app.config for libraries (DLLs)? If not, what is the easiest way to store configuration settings that are specific to a library? Please consider that the library might be used in different applications. You can have separate configuration file, but you'll have to read it "manually", the ConfigurationManager.AppSettings["key"] will read only the config of the running assembly. Assuming you're using Visual Studio as your IDE, you can right click the desired project → Add → New item → Application Configuration File This will add App.config to the project folder, put your

Variables within app.config/web.config

倖福魔咒の 提交于 2019-11-26 06:27:55
问题 Is it is possible to do something like the following in the app.config or web.config files? <appSettings> <add key=\"MyBaseDir\" value=\"C:\\MyBase\" /> <add key=\"Dir1\" value=\"[MyBaseDir]\\Dir1\"/> <add key=\"Dir2\" value=\"[MyBaseDir]\\Dir2\"/> </appSettings> I then want to access Dir2 in my code by simply saying: ConfigurationManager.AppSettings[\"Dir2\"] This will help me when I install my application in different servers and locations wherein I will only have to change ONE entry in my

How to programmatically modify WCF app.config endpoint address setting?

只愿长相守 提交于 2019-11-26 05:21:26
问题 I\'d like to programmatically modify my app.config file to set which service file endpoint should be used. What is the best way to do this at runtime? For reference: <endpoint address=\"http://mydomain/MyService.svc\" binding=\"wsHttpBinding\" bindingConfiguration=\"WSHttpBinding_IASRService\" contract=\"ASRService.IASRService\" name=\"WSHttpBinding_IASRService\"> <identity> <dns value=\"localhost\" /> </identity> </endpoint> 回答1: I think what you want is to swap out at runtime a version of

App.Config change value

夙愿已清 提交于 2019-11-26 04:33:44
This is my App.Config <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="lang" value="English"/> </appSettings> </configuration> With this code I make the change lang = "Russian"; private void Main_FormClosing(object sender, FormClosingEventArgs e) { System.Configuration.ConfigurationManager.AppSettings.Set("lang", lang); } But it not change. What I'm doing wrong? You cannot use AppSettings static object for this. Try this string appPath = System.IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().Location); string configFile = System.IO.Path

Relocating app.config file to a custom path

情到浓时终转凉″ 提交于 2019-11-26 03:55:52
问题 Is it possible to relocate the whole App.Config file to a custom path? It seems a bit odd that the config file resides in the same folder as the exe, with Windows\' new approcah of saving all program settings in c:\\ProgramData and all. An additional requirement we have is to programatically specify where to find the app.config file. The reason for this being that we spawn different service instances from the same exes, and would like to store each service\'s app.config in that service\'s

How to create custom config section in app.config? [duplicate]

a 夏天 提交于 2019-11-26 03:49:37
问题 This question already has an answer here: Custom app.config Config Section Handler 3 answers I want to add a custom configuration section in my app.config file. Is there a way to do it and how can I access these settings in my program. Following is the config section I want to add to my app.config : <RegisterCompanies> <Companies> <Company name=\"Tata Motors\" code=\"Tata\"/> <Company name=\"Honda Motors\" code=\"Honda\"/> </Companies> </RegisterCompanies> 回答1: Import namespace : using System

How to make spring inject value into a static field

痞子三分冷 提交于 2019-11-26 02:29:07
问题 I know this may looks like a previously asked question but I\'m facing a different problem here. I have a utility class that has only static methods. I don\'t and I won\'t take an instance from it. public class Utils{ private static Properties dataBaseAttr; public static void methodA(){ } public static void methodB(){ } } Now I need Spring to fill dataBaseAttr with database attributes Properties.Spring config is: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <beans xmlns=\"http://www

Equivalent to &#39;app.config&#39; for a library (DLL)

*爱你&永不变心* 提交于 2019-11-26 01:57:25
问题 Is there an equivalent to app.config for libraries (DLLs)? If not, what is the easiest way to store configuration settings that are specific to a library? Please consider that the library might be used in different applications. 回答1: You can have separate configuration file, but you'll have to read it "manually", the ConfigurationManager.AppSettings["key"] will read only the config of the running assembly. Assuming you're using Visual Studio as your IDE, you can right click the desired