Configuration madness, I have an app.Config but my object looks to web.Config?

Up vote 1 down vote favorite share g+ share fb share tw.

If you have a class library project that acts as your DAL and it has an App. Config file with connectionstrings, how can I force it to use that config file? It keep getting values from the web.

Config in my Web Application project. The DAL project uses LinqToSql. When I instansiate a DataContext object in my Web Application, from the referenced DAL Class Library project, can I make it use it's app.

Config connectionstrings? It seems to ignore this file and tries to pick up connectionstrings from the web. Config connectionstrings node.

There are no connectionstrings present there. Any help is appreciated. A colleague mentioned making the app.

Config in the DAL and embedded resource. Does that sounds like a good idea? Thanks, ~ck in San Diego asp.net configuration web-config app-config link|improve this question asked Aug 19 '09 at 23:39Hcabnettek1,9182354 67% accept rate.

Web applications always use web.config. Desktop applications always use app.config.

If you need to override it, I'd move the configuration settings either to web. Config or to an XML file that you can manage and deploy manually. – Jeff Siver Aug 20 '09 at 0:36.

It keep getting values from the web. Config in my Web Application project. You can't.

If you use the System. Configuration classes, they will always pull from the active application's . Config file (app.

Config for executables, web. Config for asp.net websites). Workarounds include using file i/o for reading your settings out (as opposed to the System.

Configuration namespace) or putting your DAL configuration information in the appropriate . Config file (the more common choice).

I'm not sure, but take a look at that: using System. Configuration; ExeConfigurationFileMap Map = new ExeConfigurationFileMap(); Map. ExeConfigFilename = FileName; Configuration Conf = ConfigurationManager.

OpenMappedExeConfiguration(Map, ConfigurationUserLevel. None); AppSettingsSection section = (AppSettingsSection)Conf. GetSection("?

").

Here's how I think of a *. Config file. Say you have a method in your DAL: DoSomething(connectString, SqlDialect, businessObject) Since connectString and SqlDialect don't change with every call to this method, it would be nice to be able to remove those parameters and get those through some other means.

Well, *. Config files are there for that reason--they are not only environment-specific, they are also app-specific. It's so your Web app can say, " connectString = "..." and SqlDialect = "...", for every method call, until I say otherwise.

" Let's say you want one app to log into SQL with one set of credentials, and another app to use another set of credentials (with different perms if necessary) so that the DBA can keep track of which app is doing what (if he/she so chooses). Well, *. Config files make this happen.

That's why the app that you're running is the one that provides the *. Config file. So just cut all the contents from your DAL's app.

Config file and paste it into your Web. Config file, then delete App.config. You should be good-to-go after that.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions