app-config

sub appsettings in the appsetting node c#

前提是你 提交于 2019-11-29 22:12:55
I am using the app.config file that is created with a console application and I can read the val1 of the key1 using the ConfigurationSettings.AppSettings["key1"].ToString() <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> </startup> <appSettings> <add key="key1" value="val1" /> <add key="key2" value="val2" /> </appSettings> </configuration> but I have too many keys and values that I want to make them categorized. I found something that is difficult to use in my application since I want to access the keys in a similar way to the above one Showing

Windows service installer not reading App.Config file

邮差的信 提交于 2019-11-29 21:12:43
问题 I have added App.Config in my project. I have a installer class(ProjectInstaller.cs) which needs to read values from App.config. I am providing the keys . Below is the sample Code : ConfigurationManager.AppSettings["CONFIG_FILE"] I am getting null values as per above code ,when invoked in Installer class. But in App.Config file the value for the above key exists. 回答1: Try: public string GetServiceNameAppConfig(string serviceName) { var config = ConfigurationManager.OpenExeConfiguration

Custom Configuration for app.config - collections of sections?

孤者浪人 提交于 2019-11-29 19:14:24
问题 My head is absolutely pounding badly! I have done this before but not as "in depth" or complex as this and I have tried different ways to make this happen but all has failed. So, this is the custom XML I want in the app.config: <Profiles> <!--Collection--> <Profile Name="Live"> <Components> <Component Name="Portal" Type="Web" /> <Component Name="Comms" Type="Web" /> <Component Name="Scheduler" Type="WindowsService" ServiceName="LiveScheduler" /> </Components> <Databases> <Database Name="Main"

ConfigurationProperty is inaccessible due to its protection level

喜欢而已 提交于 2019-11-29 18:20:50
问题 I wanna read/write (and save) application's configuration file in program The app.config is like this: <configuration> <configSections> <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler" requirePermission="false"/> </configSections> <AdWordsApi> <add key="LogPath" value=".\Logs\"/> ... </AdWordsApi> </configuration> When I use ConfigurationManager.GetSection to read the app.config, it works: var adwords_section = (System.Collections.Hashtable) System.Configuration

C# Set probing privatePath without app.config?

房东的猫 提交于 2019-11-29 17:40:00
问题 I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just like how it checks its current directory. If I created a App.Config with this information: <?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="Data" /> </assemblyBinding> </runtime> </configuration> It works without a problem. I do not want to have an

Is it possible to split a string across multiple lines in an XML file? If so, how?

谁说我不能喝 提交于 2019-11-29 16:46:30
问题 I've got an XML config file with some really long strings. Generally, I format my source files, etc. so that they can be read without scrolling. I'd like to do the same to this config file. Is there a way to split the string across more than one line? Hopefully, what I'm asking for is obvious but a picture says a thousand words so, e.g. value, below. <add name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.ValidationElement, Microsoft.Practices

Deploying connection string encrypted via RSAProtectedConfigurationProvider in app.config

倖福魔咒の 提交于 2019-11-29 15:25:29
问题 If a developer encrypts a connection string app.config section using RSAProtectedConfigurationProvider on their own machine, and this is subsequently deployed to a user's workstation, can that user's workstation (or server, for that matter), decrypt the connection string automatically? Would some kind of key export/installation be required? How does this work? I realize that it's not bulletproof. I'm looking for advice on whether or not the deployment would be easy and/or work with such an

Problems with Web.config and App.config

若如初见. 提交于 2019-11-29 14:56:56
问题 Intro: Normally we store ConnectionStrings and some other settings ( <appSettings> <add key... ) in the Web.config or App.config . My scenery: Web application using factory pattern with direct injection to read data providers. In the web.config I have the key that tells me which DLL (provider) will I use to retrieve my data. I can have more than one provider (each DLL will be a provider for MS SQL, MySQL, or get the data from some SOA service). Each DLL has his own name (ID and namespaces)

How to Save Configuation in app.config in C# Winforms

一世执手 提交于 2019-11-29 14:19:54
问题 Can someone give me an example of how to save a key/value in app.config using C# and WinForms? 回答1: In ASP.NET : Configuration config = WebConfigurationManager.OpenWebConfiguration(null); AppSettingsSection app = config.AppSettings; app.Settings.Add("x", "this is X"); config.Save(ConfigurationSaveMode.Modified); In WinForms : Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); AppSettingsSection app = config.AppSettings; app.Settings.Add("x", "this

How to include simple collections in ConfigurationSection

巧了我就是萌 提交于 2019-11-29 13:29:05
Is there a way for me to include a simple array of strings, or List<string> on my custom subclass of ConfigurationSection? (Or an array or generic list of simple data objects, for that matter?) I'm becoming familiar with the new (and VERY verbose) ConfigurationSection, ConfigurationElement, and ConfigurationElementCollection classes, but I'm by no means an expert yet. It seems like ConfigurationSection should handle simple collections/lists on its own, without me having to create a custom ConfigurationElementCollection subclass for each and every one. But I haven't found any reference to this