By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

Using 2 Web.config or App.config

P: n/a
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,
--

Daniel Andrade Groh
CTF Technologies
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Daniel Groh" <ne*********@gmail.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
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,
--

Daniel Andrade Groh
CTF Technologies

Nov 17 '05 #2

P: n/a
Dan
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

Nov 17 '05 #3

P: n/a
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 ?

--

Daniel Andrade Groh
CTF Technologies
"W.G. Ryan eMVP" <Wi*********@gmail.com> escreveu na mensagem
news:uQ**************@TK2MSFTNGP09.phx.gbl...
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.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Daniel Groh" <ne*********@gmail.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
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,
--

Daniel Andrade Groh
CTF Technologies


Nov 17 '05 #4

P: n/a
No Dan, it doesnt...it opens from the WebApplication and not from the Class
Library Application...Should not specify something else ? for sure ? =/

--

Daniel Andrade Groh
CTF Technologies
"Dan" <da*************@yahoo.com> escreveu na mensagem
news:11*********************@z14g2000cwz.googlegro ups.com...
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

Nov 17 '05 #5

P: n/a
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

Nov 17 '05 #6

P: n/a
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

"Clint (cm******@online.nospam)" <cj*******@gmail.com> escreveu na mensagem
news:11*********************@g14g2000cwa.googlegro ups.com...
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

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.