app-config

Can we have multiple App.Config files in .NET console application?

此生再无相见时 提交于 2019-11-28 03:15:35
问题 I have a console application that has App.Confile file. Now the parameters that are environment specific are maintained here. Now I am thinking to have multiple app.config files (like app.dev.config, app.test.config and app.prod.config ) the way how we can have multiple Web.Config files. In case of Web application, we can handle this and ConfigurationManager would pick respective Web.Config file. In case of Console application, I am not sure. If Yes, how can we have multiple app.config files?

How do you use sections in c# 4.0 app.config?

核能气质少年 提交于 2019-11-28 03:08:16
I want to use my app config to store the settings for 2 companys, and i'd prefer if it was possible to use a section to seperate the data for one from the other rather then giving them diffrent key names. I have been checking online but i seem to get a bit overwhelmed when people use sections or find outdated easy ways to use them. could anyone pass me a beginner guide on them? Below is an example of what my app.config would look like: <configSections> <section name="FBI" type="" /> <section name="FSCS" type="" /> </configSections> <FSCS> <add key="processingDirectory" value="C:\testfiles

ConnectionString from app.config of a DLL is null

南笙酒味 提交于 2019-11-28 02:04:28
问题 I have a class library that contains a valid connectionString inside the app.config. Inside that class library I want to use it with ConfigurationManager.ConnectionStrings["NAME"].ConnectionString My ASP.net 4.0 framework application references that DDL and retrieves data from it. I want create a Entity Framework 4 DataContext within my DDL with the ConnectionString from the App.config. (I do not want to pass the connectionString from my ASP.net application in every single method. (I'm using

moving the config files for a dll to the app that calls the dll

ぐ巨炮叔叔 提交于 2019-11-28 02:01:41
I have a web app that has search functionality. The search algorithm is compiled to a separate dll. In the C# code for the search algorithm, I am using strings held in a settings file to point to the directory where the search index resides. Once the search code is compiled, the settings info is incorporated in Search.dll.config which is put in the bin directory along with Search.dll. Now in my web app, I add Search.dll to the references. The config file is not added into the web app. However the web app runs fine and knows where the file is. Because inside Settings.Designer it uses the

Setting the service URL at runtime

馋奶兔 提交于 2019-11-28 01:32:55
When I am adding the "Web Reference" we are giving the address to the asmx page to visual studio. How Can I set this at run time? Just set the Url property of the object before you call any of the service methods: YourService service = new YourService(); service.Url = "http://some.other.url/"; // Now you're ready to call your service method service.SomeUsefulMethod(); I would have upvoted one of the other answers - they're almost correct. using (YourService service = new YourService()) { service.Url = "http://some.other.url/"; // Now you're ready to call your service method service

App.config connection string Protection error

一世执手 提交于 2019-11-28 01:32:41
I am running into an issue I had before; can't find my reference on how to solve it. Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below: config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) If config.ConnectionStrings.SectionInformation.IsProtected = False Then config.ConnectionStrings.SectionInformation.ProtectSection(Nothing) ' We must save the changes to the configuration file.' config.Save(ConfigurationSaveMode.Modified, True) End If The issue is we had a salesperson leave. The old laptop is

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

邮差的信 提交于 2019-11-28 01:27:47
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, ReleaseServiceInstanceOnTransactionComplete = false )] public class WorkImplementation : IWork a servicehost (windows service or console

Writing custom sections into app.config

天大地大妈咪最大 提交于 2019-11-27 23:52:49
问题 I want to save some custom data into application configuration file and I need to create some custom sections in app.config. Reading custom data from app.config is simple task, but I can't write information from my programm into app.config. For finding solution of this problem I create test project. For reading data from custom section app.config I used information from this article: http://devlicio.us/blogs/derik_whittaker/archive/2006/11/13/app-config-and-custom-configuration-sections.aspx

App.config connection string relative path

泪湿孤枕 提交于 2019-11-27 22:13:53
I need to set in the app.config the sqlite connection string. I want to set the path relative to the debug/release folders the database file will be copied to those folders. <add name="EmailsSQLite" connectionString="data source=c:\Users\Test\Documents\Visual Studio 2008\Projects\TestConsole\Emails\data\EmailDatabase.sqlite" providerName="System.Data.SQLite"/> and I want to have something like: <add name="EmailsSQLite" connectionString="data source=\data\EmailDatabase.sqlite" providerName="System.Data.SQLite"/> Is that possible? You can specify a relative path as described in Lefty's answer.

Is there a way to override ConfigurationManager.AppSettings?

余生长醉 提交于 2019-11-27 21:12:38
I really want to be able to have a way to take an app that currently gets its settings using ConfigurationManager.AppSettings["mysettingkey"] to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section for handling this sort of thing, but I really don't want other developers on my team to have to change their code to use my new DbConfiguration custom section. I just want them to be able to call AppSettings the way they always have but have it be loaded from a central database. Any ideas? If you don't mind hacking around