system.configuration

The best way to get a path to machine.config of a different .NET version

主宰稳场 提交于 2020-01-14 03:22:11
问题 Whats the best way to get a path to .net 2.0 machine.config file, if the application is running on .net 4.0? One way would be to do string manipulation and file system access to replace v4.0* with v2.0* in new ConfigurationFileMap().MachineConfigFilename; and then pass it to ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(<HERE>)) . I will resort to this solution if nothing better is available. 回答1: Since I needed the path to machine.config for ASP.NET versions, I

Is it possible to read XML using System.Configuration

笑着哭i 提交于 2019-12-24 12:22:10
问题 Currently i am using XElement for parsing XML and read each node which required by application. Now i want to read XML by using System.Configuration .Is this possible, what i think.My config.xml have not any configuration section .It just plain XML . <?xml version="1.0" encoding="utf-8" ?> <ConfigSetting> <!--The reports name which needs to be changed in to tethystrader db created on the fly.--> <ReportsName value="Tethys_Price_report,Tethys_Liquidity_report,Tethys_Liquidity_report_option"/>

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

一笑奈何 提交于 2019-12-20 03:06:12
问题 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

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

筅森魡賤 提交于 2019-12-18 10:22:52
问题 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=

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

ⅰ亾dé卋堺 提交于 2019-12-17 10:26:08
问题 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=

I get a system.configuration.settingspropertynotfoundexception error in windows service

一曲冷凌霜 提交于 2019-12-12 17:26:01
问题 I have a windows app that uses SettingsProvider to read configuration settings and sets default values if file does not exist. It works fine running normally. I am trying to write a windows service that starts this app. When it is run by the service, I get System.Configuration.SettingsPropertyNotFoundException on all the setting attributes. How can I resolve this exception when the service is running the app? 回答1: This simply means that the app can't read the .Settings file. I can think of

Using .NET ConfigurationManager to read settings from a string instead of an app.config file

余生颓废 提交于 2019-12-08 00:48:08
问题 We are running multiple instances of our service (implemented as a .exe file) on different machines in our data center. However, we would like to store configuration parameters for this .exe file in a central location (as opposed to being in the .exe.config per machine). To do this, we are planning to move the content of the .exe.config files to an attribute in a central repository (Active Directory or SQL) and make the .exe's running on all machines read from this repository. I would like

The best way to get a path to machine.config of a different .NET version

*爱你&永不变心* 提交于 2019-12-07 17:59:25
Whats the best way to get a path to .net 2.0 machine.config file, if the application is running on .net 4.0? One way would be to do string manipulation and file system access to replace v4.0* with v2.0* in new ConfigurationFileMap().MachineConfigFilename; and then pass it to ConfigurationManager.OpenMappedMachineConfiguration(new ConfigurationFileMap(<HERE>)) . I will resort to this solution if nothing better is available. Since I needed the path to machine.config for ASP.NET versions, I didn't care about all .NET framework paths (e.g. 3 and 3.5 frameworks since they are just extensions of 2.0

Using .NET ConfigurationManager to read settings from a string instead of an app.config file

与世无争的帅哥 提交于 2019-12-06 08:17:19
We are running multiple instances of our service (implemented as a .exe file) on different machines in our data center. However, we would like to store configuration parameters for this .exe file in a central location (as opposed to being in the .exe.config per machine). To do this, we are planning to move the content of the .exe.config files to an attribute in a central repository (Active Directory or SQL) and make the .exe's running on all machines read from this repository. I would like reuse all the existing classes used for reading/writing configuration information (using

ConfigurationElementCollection with a number of ConfigurationElements of different type

断了今生、忘了曾经 提交于 2019-12-05 17:10:00
问题 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