app-config

developer specific app.config/web.config files in Visual Studio

∥☆過路亽.° 提交于 2019-11-28 15:10:38
We have several .NET projects where we store certain settings in config files. Now each developer will have their own config files that differ a little (different connection strings to connect to local db, different WCF endpoints etc.) At the moment we tend to check out app/web.config files and modify them to suit our needs. This leads to many problems since from time to time someone will check in their own settings or loose custom config when getting latest version from tfs. My question is: how do you deal with situations like this? Or you don't have this problem at all? We use a system that

Can you have a generic List(of T) in your settings file?

萝らか妹 提交于 2019-11-28 13:24:02
In my settings file, I would like to have one setting that is of the type List(of Myclass).... I can't find anything on the net that does this. Is it possible? I assume you're talking about user settings... I don't know if you can specify a generic type, although if you create your own non-generic type which inherits from List(of MyClass), then you can specify this type as your user setting without any problem. Something like: Public Class MyClassList Inherits List(Of MyClass) End Class Then you should be able to browse for MyClassList . I agree that Meta-Knight's inheritance solution is best,

how to determine whether app.config file exists

自作多情 提交于 2019-11-28 13:21:03
Is there a way to find out whether an app.config file exists, without using "File.Exists"? I tried if ( !ConfigurationManager.ConnectionStrings.ElementInformation.IsPresent ) {...} but IsPresent is false even if app.config with a connection string exists. Edit: Did I misinterpret the IsPresent Property? Most simple way that I can think of is to add some "dummy" application setting flag then check for that flag, e.g.: if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["dummyflag"])) { //config file doesn't exist.. } The AppDomain reports on where it expects the configuration file for the

C# applicationSettings: how to update app.config?

风格不统一 提交于 2019-11-28 12:24:14
I am using .NET 4.0 and I would like to use the app.config file to store same parameter settings. I do the following. I use the Settings tab in the project properties to create my parameters. This add the information in the app.config file like this: <MyApp.Properties.Settings> <setting name="param1" serializeAs="String"> <value>True</value> </setting> <MyApp.Properties.Settings> In my view model (in my code) I can access to the information in this way: bool myBool = MyApp.Properties.Default.param1; When I try to change the value in the config file, I try this: Properties.Settings.Default

Read from App.config in a Class Library project

梦想的初衷 提交于 2019-11-28 11:58:22
I am developing a simple class library project, which will give me a dll. I wanted a particular value to be read from a config file. So I have added an App.config file to my project. <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="serviceUrl" value="test value" /> </appSettings> </configuration> Above is my App.config file, and now I am trying to read it as following string strVal = System.Configuration.ConfigurationManager.AppSettings["serviceUrl"]; But I am not getting any value in my string variable. I had done this for a web application in a similar way and

How to use Application Data in an (App.config) connectionString

穿精又带淫゛_ 提交于 2019-11-28 11:33:37
I've got an SQL Server CE database in a project that I wan't to store somewhere in the %AppData% directory. However I can't find a way to make a reference to the Application Data path in the connection string (in the App.Config) <?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="EntityConnectionString" connectionString="metadata=res://*/EntityModel.csdl|res://*/EntityModel.ssdl|res://*/EntityModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string="Data Source=|ApplicationData|\Entities.sdf"" providerName="System.Data

Nested Configuration Section app.config

爷,独闯天下 提交于 2019-11-28 09:44:52
I don't find any examples of how to access such a nested configuration section in a app.config <my.configuration> <emailNotification> <to value="me@you.com" /> <from value="he@you.com" /> <subject value="Subject" /> <smtpHost value="smtp.you.com" /> <triggers> <add name="1" varAlias="Var1" lower="-200" upper="-150"/> </triggers> </emailNotification> </my.configuration> I used ConfigurationElementCollection and ConfigurationElement before. But I don't know how to do the above? You need to: Define my.configuration as section group and emailNotification as a section within the group. Add

Encrypting sections and-or settings in an App.config file that will be redistributed

时间秒杀一切 提交于 2019-11-28 09:22:56
I'm creating a regular windows application that will be distributed to several users on my department. I'll need to include some connectivity passwords on the App.config file, and I obviously don't want end-users to just fire up notepad and look at the passwords. Several articles point on how to encrypt/decrypt configuration sections, but it appears you have to share/ship some keys with the deployable solution. Is there a simpler way, to just cipher some of the settings so that they are not user-readable, but that don't require extra steps or files when redistributing the program? Great plus

WCF inactivity timeout

一曲冷凌霜 提交于 2019-11-28 08:46:44
问题 I have created a very simple WCF service, hosted on windows service, closely following the example on MSDN here: http://msdn.microsoft.com/en-us/library/ff649818.aspx If I make a 2nd call to my service > 10 mins after my first call, I'll get a inactivity timeout error. I understand that this is the default setting of the WCF client. However, when I change my app.config from <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> to <reliableSession ordered="true"

How to Read Custom XML from the app.config?

为君一笑 提交于 2019-11-28 08:38:29
I want to read the custom XML section from the app.config of a C# windows service. How do I go about it? The XML is below: <Books> <Book name="name1" title="title1"/> <Book name="name2" title="title2"/> </Books> What you want to do is read up on Custom Configuration Sections . Kevin Nisbet In a project I developed I use something similar for configuration that I found. I believe the article was called the last configuration section handler I'll ever need (I can't find a working link, maybe someone can link it for me). This method takes what you want to do one step further, and actually de