473,472 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2265
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.