app-config

Encrypting connectionStrings section - utility for app.config

随声附和 提交于 2019-11-27 07:49:33
Is there a utility that will encrypt a named configuration section (or just the connectionStrings section) in an app.config file in a similar manner that one can use aspnet_regiis with web.config files? I know this can be done in code - there are code examples out there, but I am hoping to avoid writing an application for this. RBZ You can try the following: https://magenic.com/thinking/encrypting-configuration-sections-in-net In short - rename the app.config file to web.config - the schema is identical, so aspnet_regiis works. Rename back to app.config when finished. Old question, but here is

how to determine whether app.config file exists

扶醉桌前 提交于 2019-11-27 07:45:34
问题 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? 回答1: 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"])

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

十年热恋 提交于 2019-11-27 07:38:22
问题 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? 回答1: 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

Visual Studio always selects the wrong xsd for App.config

我的未来我决定 提交于 2019-11-27 06:45:45
first of all, I have a .NET 4.0 application with this configuration: <?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration> I had the same problem like the one in this question: app.config "Could not find schema information" after converting to Visual Studio 2010 / .Net 4.0 : The supportedRuntime element was not recognized by the editor, resulting in a hint. I then followed the answer: I was in the app.config editor and went to the Properties window. There I selected the Schemas entry. I removed the

Read from App.config in a Class Library project

馋奶兔 提交于 2019-11-27 06:37:49
问题 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

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

核能气质少年 提交于 2019-11-27 06:24:21
问题 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

How to Read Custom XML from the app.config?

霸气de小男生 提交于 2019-11-27 05:47:46
问题 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> 回答1: What you want to do is read up on Custom Configuration Sections. 回答2: 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

Visual Studio/MSBuild copy referenced class library's app.config as *.dll.config to bin folder of current project

蓝咒 提交于 2019-11-27 05:45:52
问题 I have a class library that is referenced by many other web application projects. It has many settings in its app.config that I wish to use in all of the referencing web projects. When the class library is built, it copies the app.config to its own bin folder as <assembly.name>.dll.config . How do I ensure that <assembly.name>.dll.config is copied to the bin folder of each of my referencing web application projects? Visual Studio / MSBuild does not seem to do this by default. Changing Copy to

.Net Encryption

随声附和 提交于 2019-11-27 05:19:56
问题 What I would like to know is the definite approach to encrypting connection strings in a config file. Here are my questions: Using machine-level encryption, can't anybody accessing my server write a little .Net program to read the contents of the connection strings? If I am deploying my application to users machines in an enterprise environment, and the application has connection strings in a config file, how can I make sure only my application can decrypt it? The scenario is especially

WCF service: app.config versus attributes or a mixture of both

▼魔方 西西 提交于 2019-11-27 04:48:18
问题 In a WCF application we have a servicecontract with attributes: namespace We.Work { [ServiceContract(Namespace = "We", Name = "IWork", SessionMode = SessionMode.NotAllowed)] public interface IWork an implementation of the servicecontract with attributes: namespace We.Work { [ServiceBehavior(Name = "Work", Namespace = "We", IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple,