Using 2 Web.config or App.config

  • Thread starter Thread starter Daniel Groh
  • Start date Start date
D

Daniel Groh

Hi Sirs,
Could I use 2 config files in the same solution ? I have 2 projects in my
solution (Data - Class Library, MySite - Web Application)
But the funcking =/ problem happens because i want the connection string in
the Data Project (Class Library), How do i do ?
Could I access a config file in the Data project to get the connection
string through from (app settings) ?

Kind regards,
 
I'm not sure I understand the problem specifically but the short answer is
that you definitely can have multiple app.config files - one for each
project for instance. YOu can also just create a centralized XML file
somewhere and use it.
 
All of the the values you will store in the config should be in the
app.config of the executing assembly. There is no use in having an
app.config for a dll. I have remoted objects (class libraries) that
need connection strings. These strings are part stored in the
app.configs of the services hosting those remote objects. When I
deploy a remote object to a server, I add any info needed to the
service config at the same time.

When you read app settings from a class lib it will automatically open
the app config of the calling assembly.

HTH,
Dan
 
I tryed: Cinfiguration.AppSettings("MSSQL")

But it does not bring to me from the Data project but yes from the
WebApplication project...should i not make some especification to access thi
config file in the Data project ?
 
No Dan, it doesnt...it opens from the WebApplication and not from the Class
Library Application...Should not specify something else ? for sure ? =/
 
I assume you mean if you put the MSSQL appsetting into the Web
Application .config file, you get a result, but if you put MSSQL in the
Class Library's .config file, you get nothing, right? If that's the
case, Dan's right - in this regard, the Web Application is the calling
assembly, not the Class Library. I might be mistaken, but I don't think
a class library can be a calling assembly for a .config file, as it's
never executed stand-alone - you need an EXE or some other process to
load it up.

Clint
 
Alright...so...the most usual and easily form to make that is: use the
web.config from you web application...hehehe right ?

Thank you all...Danke sehr!

Daniel
 
Back
Top