c# - Accessing Web.config from another Project -


i writing test platform semi-automated testing using console application, need connection string project testing. don't want reference other application directly or otherwise have accessor in project i'm testing.

what i've managed far create link other project's web.config file in testutility project, , i've set copy if newer. it's web.config in test project's root folder, webconfigurationmanager.openwebconfiguration(null) seems opening other web.config, connection string in refers .\sqlexpress (not in file in solution, path .\sql2008 in configuration - varies).

any hints or tips how access config section project?

(yay first question)

better late never:

var filepath = @"d:\pathtoconfig\web.config"; var map = new execonfigurationfilemap { execonfigfilename = filepath }; var configfile = configurationmanager.openmappedexeconfiguration(map, configurationuserlevel.none); 

i can't take credit 1 though, found here!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -