system.configuration

ConfigurationElementCollection with a number of ConfigurationElements of different type

邮差的信 提交于 2019-12-04 02:09:51
Is it possible to have a CollectionElementCollection with a number of different by type CollectionElements, e.g.: <collection> <add type="MyType1, MyLib" Type1SpecificProp="1" /> <add type="MyType2, MyLib" Type2SpecificProp="2" /> </collection I have all classes required for such solution: class MyCollection : ConfigurationElementCollection { } class MyElement : ConfigurationElement { } class MyType1 : MyElement { } class MyType2 : MyElement { } ... etc but when I start my application I'm getting next predictable error: Unrecognized attribute 'Type1SpecificProp'. because Type1SpecificProp is

reading external configuration file

限于喜欢 提交于 2019-12-03 05:55:00
问题 I have a c# .Net console app that performs FTP operations. Currently, I specify the settings in a custom configuration section, e.g. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="ftpConfiguration" type="FileTransferHelper.FtpLibrary.FtpConfigurationSection, FileTransferHelper.FtpLibrary" /> </configSections> <ftpConfiguration> <Environment name="QA"> <sourceServer hostname="QA_hostname" username="QA_username" password="QA_password" port="21"

reading external configuration file

喜夏-厌秋 提交于 2019-12-02 20:34:32
I have a c# .Net console app that performs FTP operations. Currently, I specify the settings in a custom configuration section, e.g. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="ftpConfiguration" type="FileTransferHelper.FtpLibrary.FtpConfigurationSection, FileTransferHelper.FtpLibrary" /> </configSections> <ftpConfiguration> <Environment name="QA"> <sourceServer hostname="QA_hostname" username="QA_username" password="QA_password" port="21" remoteDirectory ="QA_remoteDirectory" /> <targetServer downloadDirectory ="QA_downloadDirectory" /> <

Type cant be resolve in UnitTest after migrating Project from vs2005 to vs2010 (MSTest)

雨燕双飞 提交于 2019-12-02 00:30:42
We are actually analyzing what we have to do if we migrate our application from VS2005 up to VS2010. What i have done: I opened all solutions in VS2010 and let convert vs the projects. At the moment the production assemblies dont get an upgrade of the .NET Framework, it has to target the framework 2. The framework version of the unit test assemblies ( MSTest ) is switched to the version 4 by VS2010 automatically, thats ok so far. The Problem: Some unit tests are failing cause they can't access a config file through the ConfigurationMananger.OpenExeConfiguration(ConfigurationUserLevel.None)

Where is ConfigurationManager's namespace?

拥有回忆 提交于 2019-11-30 14:27:46
问题 I've got a reference to System.Configuration - and ConfigurationSettings is found no problem - but the type or namespace ' ConfigurationManager ' could not be found!? I've read around - and it looks like it should belong to the same namespace as the ConfigurationSettings class. EDIT: Please take note - I've clearly said I have added a reference to System.Configuration . There's been 4 comments already about this. 回答1: ConfigurationManager is a part of the System.Configuration after .Net 2.0.

Where is ConfigurationManager's namespace?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 10:50:05
I've got a reference to System.Configuration - and ConfigurationSettings is found no problem - but the type or namespace ' ConfigurationManager ' could not be found!? I've read around - and it looks like it should belong to the same namespace as the ConfigurationSettings class. EDIT: Please take note - I've clearly said I have added a reference to System.Configuration . There's been 4 comments already about this. ConfigurationManager is a part of the System.Configuration after .Net 2.0. Add a reference to the System.Configuration dll. Try using System.Configuration.ConfigurationManager. You

Using ASPNet_Regiis to encrypt custom configuration section - can you do it?

江枫思渺然 提交于 2019-11-29 20:57:36
I have a web application with a custom configuration section. That section contains information I'ld like to encrypt (was hoping to use ASPNet_RegIIS rather than do it myself). Web.Config: <?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <configSections> <section name="MyCustomSection" type="MyNamespace.MyCustomSectionHandler, MyAssembly"/> </configSections> <configProtectedData> <providers> <clear /> <add name="DataProtectionConfigurationProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0

Get the App.Config of another Exe

两盒软妹~` 提交于 2019-11-28 23:02:04
I have an exe with an App.Config file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities. The question is how can I access the app.config property in the exe from the wrapper dll? Maybe I should be a little bit more in my questions, I have the following app.config content with the exe: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myKey" value="myValue"/> </appSettings> </configuration> The question is how to how to get "myValue" out from the wrapper dll? thanks for your solution. Actually my initial concept was

How to Create a Configuration Section That Contains a Collection of Collections?

天涯浪子 提交于 2019-11-27 18:31:02
I need a configuration section something like this: <myConfig> <mySubConfig1> <mySubSubConfig1 keyAttribute="value1"> <mySubSubConfig1Element keyAttribute="value1"/> <mySubSubConfig1Element keyAttribute="value2"/> </mySubSubConfig1> <mySubSubConfig1 keyAttribute="value2"> <mySubSubConfig1Element keyAttribute="value1"/> </mySubSubConfig1> </mySubConfig1> <mySubConfig2> <mySubSubConfig2 keyAttribute="value1"> <mySubSubConfig2Element keyAttribute="value1"/> <mySubSubConfig2Element keyAttribute="value2"/> </mySubSubConfig2> <mySubSubConfig2 keyAttribute="value2"> <mySubSubConfig2Element

Get the App.Config of another Exe

孤者浪人 提交于 2019-11-27 14:30:46
问题 I have an exe with an App.Config file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities. The question is how can I access the app.config property in the exe from the wrapper dll? Maybe I should be a little bit more in my questions, I have the following app.config content with the exe: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myKey" value="myValue"/> </appSettings> </configuration> The question is how to