app-config

Change App.config during installation

我的未来我决定 提交于 2019-12-06 02:59:57
问题 I have XML-file with settings 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="UpdateReportService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <

How to access a connection string from within a library

五迷三道 提交于 2019-12-06 02:38:20
问题 I have a web project (mvc) and data access layer in a separated class library project. I need to access to a connection string in app.config which sits in that library project. ConfigurationManager.ConnectionStrings[0].ConnectionString pulls something strange. I don't have this kind of settings neither in the library's config nor in the web project's config files. the App.config looks like that: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name=

How do you restart an app/reread app.config file when modified (.NET)?

China☆狼群 提交于 2019-12-06 02:38:19
问题 We all know that modifying a .NET web application's web.config file restarts the app and makes it read the updated configuration. How do you do that with a console or WinForms app? Thanks :) 回答1: Probably need a FileSystemWatcher to monitor the file, and handle the relevant event. The System.Configuration.ConfigManager class might have the relevant methods to reload (method call or some such). I don't have VS in front of me, but I'd say there's definately some hooks there for sure. 回答2: Use

Different configuration settings per developer for c# class library

為{幸葍}努か 提交于 2019-12-06 02:17:10
问题 We're a small team, working on a asp.net web project, as well as service, both projects dependent on a shared class library. We'd like to have the class library settings different per developer (and later on for production). In settings are included sensitive information, such as passwords, as well as hostnames. How should we assign these settings ? Unless I'm wrong, web.config/application settings aren't good enough, as they don't work for the shared class library. ps: Also, some variables

When are settings from app.config actually read?

牧云@^-^@ 提交于 2019-12-06 01:31:08
问题 When are settings from app.config actually read by application? Suppose I have a windows service and some app settings for it. In code I have a method where some setting is used. Method is being called in every iteration, not just once during all the time. If I change the setting value through the configuration file should I restart the service for it to be "refreshed" inside or will it be accepted the next time without any interaction from my side? 回答1: You need to call ConfigurationManager

Missing <configSections> in config file after deployment

风格不统一 提交于 2019-12-06 00:53:50
Update: I had a question below but actually my problem would be solved by asking a slightly different question. Why on some machines does my application throw the error: Configuration system failed to initialize - System.Configuration - at System.Configuration.ConfigurationManager.PrepareConfigSystem() where as on other machines it does not. The error as described also here .NET 3.5 - Configuration system failed to initialize exception is caused by a missing configSections element at the top of my app.config. Of course, the problem would be resolved by putting this section in but for some

Multiple App.Config files

南楼画角 提交于 2019-12-05 22:08:58
问题 I want to separate my app.config file. For example I want to move ServiceModel part to another config file in the same project. How can I do that? Thanks. 回答1: You should be able to have an empty element with the configSource attribute set to the second file (relative to the first). See here for how to enable it for custom sections. 回答2: I found the way. I changed the tag like this. <system.serviceModel> <behaviors configSource="Behaviors.config"> </behaviors> <services configSource="Services

How do you load the app.config file into a DLL

牧云@^-^@ 提交于 2019-12-05 21:48:43
So I cant find a definitive answer to the Question. How do you load the app.config file into a DLL. I understand that generally the App.config info should be put into the executable app.config. However i am building an add-in and have to executable available. I would like to use the namespace.dll.config file to store my variables, but i need a way of loading it into the system. Do you need to build out some code to load this file in? Can you use the configurationManager namespace to make this happen easily? This example will load any *.config file from your bin directory as a new configuration

Using an external .config file in configSource produces error

岁酱吖の 提交于 2019-12-05 19:38:11
问题 I was playing around with how to use the Configuration Manager to read/write custom sections in the App.config file for a WPF application in C#. I read this excellent article on .NET 2.0 Configuration Demystified and it helped me a lot in using the config files. Here is the initial App.config file which I wrote and it works fine. App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="example" type="CustomConfig.ExampleSection, CustomConfig" /> <

Validation of double using System.Configuration validator

时间秒杀一切 提交于 2019-12-05 18:57:45
I had to create a custom configuration section for my library. One of the parameters in the configuration should be positive double. However, for some reason I could not find any Validator for double. For instance, here's how I use the integer validator: [ConfigurationProperty("someProp", IsRequired = false, DefaultValue = 15)] [IntegerValidator(MaxValue = 200, MinValue = 0)] public int SomeProperty { get { return (int)this["someProp"]; } set { this["someProp"] = value; } } I've looked through Google and was not able to find any mention of DoubleValidator or FloatValidator. Is it possible to