app-config

Can a unit test project load the target application's app.config file?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 23:57:04
I am unit testing a .NET application (.exe) that uses an app.config file to load configuration properties. The unit test application itself does not have an app.config file. When I try to unit test a method that utilizes any of the configuration properties, they return null . I'm assuming this is because the unit test application is not going to load in the target application's app.config. Is there a way to override this or do I have to write a script to copy the contents of the target app.config to a local app.config? This post kind-of asks this question but the author is really looking at it

web.config and app.config confusion

早过忘川 提交于 2019-11-26 23:03:27
I have a DLL that references a web service. The block it has put into the app.config is (I have changed the names but you'll get the idea): <applicationSettings> <DLLName.My.MySettings> <setting name="DLLName_WebReferenceName_ASMXName" serializeAs="String"> <value>http://URL/Filename.asmx</value> </setting> </DLLName.My.MySettings> </applicationSettings> My website references this DLL. The question is, what do I add to the web.config to override the above setting (alternativly, do I just put the app.config in the BIN directory)? I need to be able to override the URL for the webservice on the

Deploying and Configuring ODP.NET to work without installation with Entity Framework

被刻印的时光 ゝ 提交于 2019-11-26 21:21:48
How do you deploy and configure ODP.NET to work without installation with Entity Framework? A. How to deploy and configure Oracle.DataAccess.Client? B. How to deploy and configure Oracle.ManagedDataAccess.Client? C. What do you need to do in order to make builds with EDMXs with Oracle SSDLs work? D. What do you need to install for designer support? This answer summarizes (hopefully) all the steps required, many of which documented in various places online and might save someone hours of Googling. A. How to deploy and configure Oracle.DataAccess.Client. A.1. Download ODAC112030Xcopy_64bit.zip

App.config connection string relative path

无人久伴 提交于 2019-11-26 20:56:13
问题 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=

Accessing another projects app.config properties?

久未见 提交于 2019-11-26 20:54:39
问题 I have two projects within my solution, for this example I will call them project A and B. Project B references A. Can Project B access the app.config properties of project A? I wish to access an app key string within the app.config of A. string tfsUri = ConfigurationManager.AppSettings["TfsUri"]; 回答1: That's generally not a good idea, as you introduce hard dependencies between the projects. So if you can copy-paste config value, that will make your projects self-contained (however, this

Accessing database connection string using app.config in C# winform

独自空忆成欢 提交于 2019-11-26 20:52:26
问题 I can't seem to be able to access the app.config database connection string in my c# winforms app. app.config code <connectionStrings> <add name="MyDBConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=MySQLServerDB; Integrated Security=true" /> </connectionStrings> C# code: SqlConnection conn = new SqlConnection(); conn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["MyDBConnectionString"]; When I try the C

Is there a way to override ConfigurationManager.AppSettings?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 20:34:49
问题 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

Automatically “upgrade” user settings from previous version of app.config file?

半城伤御伤魂 提交于 2019-11-26 19:51:15
问题 Every time I compile my app and the version number changes (I have an auto-incrementing build number), I lose the user-configured app.config settings, since they're stored in the AppData folder for a specific version. Essentially, every release of my application starts from scratch as far as user settings go. While this is a mild annoyance in development, it raises the question as I approach deployment/release - if I use the app.config to store my user settings, will the user's personalized

Web.config is not transformed when debugging code

北城以北 提交于 2019-11-26 19:45:27
问题 I have a main Web.config file, and under that there is a Web.Test.config , Web.Development.Config etc. When I preview the transformation via SlowCheetah on the Test config, it appears to transform the values correctly. When I switch my build environment from Development to Testing and try to debug the application, the application runs under whatever values are in the main Web.config file (i.e. it is not transforming anything). How do I make the build environment pick the correct config when

The configuration element is not declared

↘锁芯ラ 提交于 2019-11-26 19:22:51
问题 I'm doing some work in Visual Studio 2012 Express Edition. I have added an App.config XML file as follows: <?xml version="1.0" encoding="utf-8" ?> <configuration> </configuration> The first thing that happens is a warning comes up that says "The 'configuration' element is not declared". Does anyone know why this is happening? It looks like elements can not be declared inside of until this is resolved. Thanks! This is the entire XML: <?xml version="1.0" encoding="utf-8"?> <configuration>