473,246 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Changing the Application Domain to read correct .config file

Hi,

I have created a project which contains classes to read the data from the
database. This project has an App.Config file which contains the
SqlConnection String. when this code is called from a web application and if
I need to read the connection string it is reading the connection string from
the web.config of web application. I am not knowing how to change the
Application domain so that it reads the App.config file instead of Web.config
file. please let me know.

Thnx,
Sridhar.
Jan 26 '06 #1
5 2255
app.config is an IDE "template" file that is used for executables (Console,
Windows Application, Windows Service). When the app is compiled the
app.config is copied into the runtime folder alongside the built exe and its
name is changed to "appName.exe.config".

app.config files are never normally used for a web application, only
web.config is.
Hope that helps.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sridhar" wrote:
Hi,

I have created a project which contains classes to read the data from the
database. This project has an App.Config file which contains the
SqlConnection String. when this code is called from a web application and if
I need to read the connection string it is reading the connection string from
the web.config of web application. I am not knowing how to change the
Application domain so that it reads the App.config file instead of Web.config
file. please let me know.

Thnx,
Sridhar.

Jan 26 '06 #2
Try this during start up of your application
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "C:\\YourCustomConfigFile.config");

this will force application to use the config file which is specified as
second parameter...

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET
Microsoft .NET & Security MVP

"Sridhar" <Sr*****@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hi,

I have created a project which contains classes to read the data from
the
database. This project has an App.Config file which contains the
SqlConnection String. when this code is called from a web application and
if
I need to read the connection string it is reading the connection string
from
the web.config of web application. I am not knowing how to change the
Application domain so that it reads the App.config file instead of
Web.config
file. please let me know.

Thnx,
Sridhar.

Jan 26 '06 #3
KJ
Hi Sridhar,

I know we had discussed this before. But I have a new idea for you.
Create a third web project, call it WebSettingsProvider or something
like that. Add a web service to it, the purpose of which is to return
the settings required by both the web projects and the other non-web
projects in your solution. In this manner, you can store the needed
settings in one place that is accessible by all the projects (if you
don't mind adding the web references).

Aside from this type of thing, I do not know how to do what you are
asking. Maybe someone else does...

-KJ

Jan 26 '06 #4
Hi,

I am not trying to use App.Config files in a web application. Let me
explain you clearly.

I have a web application which needs to display data from a database. I
have created a project named DBMaster. This project contains a class to read
the data from database. This project is compiled into a dll. In this project,
I am using app.config(which is named is DBMaster.Config) to get the
connection string. Now I am referring this dll from my web application. When
I am calling the functions inside DBMaster and if the functions are trying to
read connection string from DBMaster.Config it is giving error. This is
because it is trying to read the connection string from Web.Config instead of
DBMaster.Config file. I hope you understood my question. Please let me know
how I could read the correct .config file.

Thanks,
Sridhar.

"Peter Bromberg [C# MVP]" wrote:
app.config is an IDE "template" file that is used for executables (Console,
Windows Application, Windows Service). When the app is compiled the
app.config is copied into the runtime folder alongside the built exe and its
name is changed to "appName.exe.config".

app.config files are never normally used for a web application, only
web.config is.
Hope that helps.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sridhar" wrote:
Hi,

I have created a project which contains classes to read the data from the
database. This project has an App.Config file which contains the
SqlConnection String. when this code is called from a web application and if
I need to read the connection string it is reading the connection string from
the web.config of web application. I am not knowing how to change the
Application domain so that it reads the App.config file instead of Web.config
file. please let me know.

Thnx,
Sridhar.

Jan 26 '06 #5
Sridhar,
Aside from Yunus' excellent suggestion, you could also consider using the
file= atttribute in your <appSettings> section. This will allow you to use an
external file containing appSettings of your choosing.

HTH,

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sridhar" wrote:
Hi,

I am not trying to use App.Config files in a web application. Let me
explain you clearly.

I have a web application which needs to display data from a database. I
have created a project named DBMaster. This project contains a class to read
the data from database. This project is compiled into a dll. In this project,
I am using app.config(which is named is DBMaster.Config) to get the
connection string. Now I am referring this dll from my web application. When
I am calling the functions inside DBMaster and if the functions are trying to
read connection string from DBMaster.Config it is giving error. This is
because it is trying to read the connection string from Web.Config instead of
DBMaster.Config file. I hope you understood my question. Please let me know
how I could read the correct .config file.

Thanks,
Sridhar.

"Peter Bromberg [C# MVP]" wrote:
app.config is an IDE "template" file that is used for executables (Console,
Windows Application, Windows Service). When the app is compiled the
app.config is copied into the runtime folder alongside the built exe and its
name is changed to "appName.exe.config".

app.config files are never normally used for a web application, only
web.config is.
Hope that helps.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sridhar" wrote:
Hi,

I have created a project which contains classes to read the data from the
database. This project has an App.Config file which contains the
SqlConnection String. when this code is called from a web application and if
I need to read the connection string it is reading the connection string from
the web.config of web application. I am not knowing how to change the
Application domain so that it reads the App.config file instead of Web.config
file. please let me know.

Thnx,
Sridhar.

Jan 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: alf | last post by:
I receive this error in big red letters when I try to see my aspx pages: Server Application Unavailable The web application you are attempting to access on this web server is currently...
5
by: Martin Robins | last post by:
I have never dabbled with ASP.NET until now so be warned! I have created a web application with the single default form: WebForm1.aspx and when I try to display it I get this error. My...
21
by: Chris | last post by:
I'm trying to get an existing VS.NET project up on my Win2003 server and I get the following error (on the actual website page): "It is an error to use a section registered as...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
2
by: Matthew Hood | last post by:
My company has expressed a desire to convert an existing MS Access application to a full VB.NET application. My experience is with VB6 so I want to ask a few questions and get some input on the...
4
by: Srini | last post by:
I noticed that ASP.Net caches the web.config and does not reread it unless it is changed. But if you change it, it restarts the app and even session variables are cleared (Am I correct ?). I used...
7
by: Larry Neylon | last post by:
Hi there, We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config. We currently have a system that on...
13
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
4
by: pedro | last post by:
application cannot read the app.config file i have a config file for the executable i try to read it but it throws an exception when building the setup for the project vs2005 do not add the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.