app-config

How do I use .NET custom ConfigurationElement properties on descendent elements?

我怕爱的太早我们不能终老 提交于 2019-12-01 02:29:09
问题 How can I get and use an attribute set in the parent ConfigurationSection in the descendent CustomSetting element? I need this attribute when the CustomSetting element is returning the Value property. I want to format the App.config like this: <CustomSettings someProperty="foo"> <CustomSetting key="bar" value="fermeneba" /> <CustomSetting key="laa" value="jubaduba" /> </CustomSettings> I have the code working, except that I cannot find a way to access the someProperty attribute from the

“Could not find endpoint element with name…”

混江龙づ霸主 提交于 2019-11-30 23:02:31
问题 Sorry for the long problem statement...I've spent two days debugging and have a lot of notes... I have a WCF data service and another process trying to connect to it as a client via TCP and/or HTTP. I have a VERY simple test client app that seems to connect fine, but the more complicated production app cannot connect (neither TCP or HTTP). In both client projects, I let Visual Studio 2008 generate the app.config by using "Add Service Reference" and letting it pull metadata from the data

Including a service reference from a class library

不想你离开。 提交于 2019-11-30 22:28:22
问题 I have a C# class library and a startup project (a console app). The class library includes a service reference to a web service. When I try to run the project, I get an InvalidOperationException because the startup project isn't reading the class library's app.config, and it's ignoring the service reference. To get it working, I'm forced to add the same service reference to the startup project. Is there any way I can avoid this? Can I make the startup project recognize the class library's

ConfigurationProperty is inaccessible due to its protection level

我怕爱的太早我们不能终老 提交于 2019-11-30 18:37:38
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.ConfigurationManager.GetSection("AdWordsApi"); Console.WriteLine((string)adwords_section["LogPath"]);

C# how to specify the appData file path in the app.config file

为君一笑 提交于 2019-11-30 17:17:47
I am using log4net and I was to save the log file in the AppData file for win XP/Vista etc. This is my app.config file so far, and I have specified the name softphone.log. Hoewver, I am not sure how to specify the complete path to the file as each user will have a different path depending on their username. <log4net> <logger name="default"> <level value="DEBUG"/> </logger> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="softphone.log"/> <appendToFile value="true"/> <rollingStyle value="Size"/> <maxSizeRollBackup value="10"/> <maximumFileSize value

Change Microsoft Config File Encryption Method From TripleDES

余生长醉 提交于 2019-11-30 16:28:02
When encrypting ("protecting") Microsoft config sections, you get something that looks like the XML below. It follows (at least partially) the W3 spec for XML Encryption. However, in the XML below you'll see that the EncryptionMethod under the EncryptedData section is "tripledes-cbc". We would like to be able to change that to a more-secure alternative, specifically AES, which is specified in the aforementioned W3 spec as well. In many calls with Microsoft's support engineers, they are nowhere near understanding the question, much less answering it. Is there a way to change this encryption

ConfigurationSettings.AppSettings is obsolete, warning

牧云@^-^@ 提交于 2019-11-30 15:16:41
var values = new NameValueCollection { { "key", ConfigurationSettings.AppSettings["API-Key"].ToString() }, { "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) } }; What's the new way to use the app.config file? Kelsey The ConfigurationManager class in System.Configuration : ConfigurationManager.AppSettings ConfigurationManager.ConnectionStrings So your code would change to: var values = new NameValueCollection { { "key", ConfigurationManager.AppSettings["API-Key"] }, { "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) } }; Make sure you add a reference to

Loading Properties.Settings from a different file at runtime

穿精又带淫゛_ 提交于 2019-11-30 15:11:11
Is there any way to load settings from a different file other than the default App.config file at runtime? I'd like to do this after the default config file is loaded. I use the Settings.Settings GUI in Visual Studio to create my App.config file for me. The config file ends up looking like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="SnipetTester.Properties.Settings" type=

Windows service installer not reading App.Config file

℡╲_俬逩灬. 提交于 2019-11-30 14:33:58
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. Try: public string GetServiceNameAppConfig(string serviceName) { var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetAssembly(typeof(MyServiceInstaller)).Location); return config.AppSettings.Settings[serviceName].Value;

Is ConfigurationManage -> section.SectionInformation.ProtectSection() machine dependent?

给你一囗甜甜゛ 提交于 2019-11-30 13:29:30
in the code Configuration config = ConfigurationManager.OpenExeConfiguration (Application.ExecutablePath); ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection; if (!section.SectionInformation.IsProtected) { section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); } I´m getting some trouble when I move the application to another machine. is the section.SectionInformation.ProtectSection call machine dependent, meaning, I cannot copy the config file and use it on another machine ? Is there a provider (other than