473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web.config and app.config issues

Hi,
I have a question about config files. I have the following in my
application..

1. ASP.NET web application with a web.config
2. C# class library (BL and DAL) with an App.config
3. Two windows Console Applications with their own App.Config.

Now I try to retrieve a value in the DAL using this code.

string str = ConfigurationSe ttings.AppSetti ngs.Get("Value" );

This code works fine when the windows applications are running. But
when the Webapplication is running and invokes an method in the Data
Access layer, the piece of code tries to refer to the Web.Config
instead of its own app.config even though it is in the DAL. Is there
any code that will tell DAL to refer to its own config file?

Can anyone tell me if I can do what i trying to do and if yes what
changes do I need to make to my code for it to work?.
I do need the app.config at the DAL level as there are some settings
common to both the windows as well as web application and that is the
best place to put it.
Help Please,
Thanks Kalyan

Apr 4 '06 #1
4 5013
An app.config file is called "app.config " because it is the configuration
file for an application, not for a class library. When you use a class
library in any application, web or otherwise, it will use the application
configuration file for that application, which is, in this case, the
web.config file.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

<ka********@gma il.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Hi,
I have a question about config files. I have the following in my
application..

1. ASP.NET web application with a web.config
2. C# class library (BL and DAL) with an App.config
3. Two windows Console Applications with their own App.Config.

Now I try to retrieve a value in the DAL using this code.

string str = ConfigurationSe ttings.AppSetti ngs.Get("Value" );

This code works fine when the windows applications are running. But
when the Webapplication is running and invokes an method in the Data
Access layer, the piece of code tries to refer to the Web.Config
instead of its own app.config even though it is in the DAL. Is there
any code that will tell DAL to refer to its own config file?

Can anyone tell me if I can do what i trying to do and if yes what
changes do I need to make to my code for it to work?.
I do need the app.config at the DAL level as there are some settings
common to both the windows as well as web application and that is the
best place to put it.
Help Please,
Thanks Kalyan

Apr 4 '06 #2
this explains how to use a config file in your library, different from
web.config:

http://www.bearcanyon.com/dotnet/#AssemblySettings

cheers

neil

Apr 4 '06 #3
Kevin, Neil thanks for your replies.
So I am now wondering if i have to modify my architecture a bit. Since
a class library cannot have an app.config (and my Business and Data
Access layers are class libraries), do I make them an console
application?.

Sorry i am new to using config files and what i need is to have a way
of letting the web and the windows components of the same application
to access certain common settings by way of the DAL.

Can you give me any suggestions on how I should organize the
components?.

Thanks

Apr 4 '06 #4
You are misunderstandin g. A class library does not need an app.config. It is
not an application. It is used in applications. Each application has its own
app.config (or web.config, which is an ASP.Net app.config file). This
enables each application to have its own configuration. When you use a class
library in an application, you put the configuration settings needed by the
class library into the app.config for that application. That way, the class
library is more flexible on a per-application basis.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

<ka********@gma il.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Kevin, Neil thanks for your replies.
So I am now wondering if i have to modify my architecture a bit. Since
a class library cannot have an app.config (and my Business and Data
Access layers are class libraries), do I make them an console
application?.

Sorry i am new to using config files and what i need is to have a way
of letting the web and the windows components of the same application
to access certain common settings by way of the DAL.

Can you give me any suggestions on how I should organize the
components?.

Thanks

Apr 5 '06 #5

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

Similar topics

10
9428
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a ConfigurationErrorException whenever I do the following: 1. Modify and save the section in code using the...
1
5129
by: Matt F | last post by:
Two of the projects in my solution that both need to use a common user.config file. This is a data application - the executable that is created with the first project is the primary executable that users will be working with 99% of the time, the other is a seperate "maintenance" executable. The connection string is stored via My.Settings...
3
1265
by: Brad | last post by:
Probably a very basic questions here: When using code to look at a web.config item, how can I tell if the value is/is not inherited? I have some common code that needs to iterate through settings like appsettings and connectionstrings but I only want to look at settings for the current web app: I would like to ignore a value if it comes...
6
4734
by: TS | last post by:
I cannot get this to work. I added an app.config to a project i reference from my web application project (vs 05) but can see no way to access the settings within it. the other thing is that I expected this config file (.dll.config) to get put in my web app's bin folder along with it's .dll file when i did a build, and that didnt' happen...
3
3607
by: SevDer | last post by:
Hi All, I am recently experiencing a weird problem. I don't know what exactly is the cause of the problem but here is my scenario and symptoms. First of all here is my architecture 1. I have a main framework (DNN) build in VB.NET which I try to prevent changing things there (simply not changing it) 2. I have a virtual directory under...
3
2266
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
I've added a web deployment project and want to use the config section replacement but I'm obviously not understanding something. I have set up an alternate appSettings file, test.appSettings.config, and when I build the appSettings are correctly overridden, but I also end up with a copy of test.appSettings.config in my web site. If I have...
1
2781
by: =?Utf-8?B?Q2h1Y2sgUA==?= | last post by:
I have an asp.net solution with a web deployment project. When we try to build/debug, we get the message: An editor or project is attempting to check out a file that is modified in memory, which will result in saving it. Saving files during the build process is dangerous and can result in incorrect build outputs in future. Do you want...
10
1644
by: =?Utf-8?B?TUNN?= | last post by:
When creating a new VB Web Application Project with VS2008, there are several settings (compiler settings, option strict, etc) that appear both in the web.config file and "My Project". I'm wondering what takes precedent, what the benefit of using one vs. the other is, and what happens if they conflict?
3
2918
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it brings me to the dir: C:\Visual Studio 2005\WebSites\WebSite1, it creates default.aspx and default.aspx.vb and I pasted the following code into...
5
2849
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a app that uses several membership/role providers. I can list these Providers with the code: Dim rootWebConfig1 As Configuration rootWebConfig1 = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) Dim section As New MembershipSection section = rootWebConfig1.GetSection("system.web/membership")
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3662
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.