473,386 Members | 1,733 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,386 software developers and data experts.

Reading config file other than web.config

Hello all,

Recently I have started working in .NET 2.0. I am developing a web
service application that references a DLL component written in C# 2.0.
The component has its own config file which contains settings related
to business logic coded in that component. I can reference and load
the component but unable to read load the custom config file of that
component. I know that the same thing is possible if my host
application is any Exe application and using
"ExeConfigurationFileMap", "OpenMappedExeConfiguration" I can read
configuration file other than app.config but the same is not possible
if I use "WebConfigurationFileMap" and "OpenMappedWebConfiguration".
Using both these we can only define the mappings b/w virtual and
physical directories but can't read config file other than
web.config.

string dummyVirtualPath = "/test_web_2005";
string physicalPath = @"C:\Inetpub\wwwroot
\test_web_2005\Bin";
string configFileName =
System.IO.Path.GetFileName(assembly.CodeBase) + ".config";
WebConfigurationFileMap map = new WebConfigurationFileMap();
map.VirtualDirectories.Add(dummyVirtualPath, new
VirtualDirectoryMapping(physicalPath, true));
Configuration config =
WebConfigurationManager.OpenMappedWebConfiguration (map,
dummyVirtualPath);

Is there any other idea to implement the same. Thanks in advance.

Regards
Irfan

Apr 17 '07 #1
1 7463
I'd consider migrating the settings in the component's config file into your
web.config, from which the componext can gain access to its settings. Any
class library that is referenced in an ASP.NET web application has access to
the settings in the main web.config settings file. All it needs is a
reference to System.Configuration.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"M Irfan" wrote:
Hello all,

Recently I have started working in .NET 2.0. I am developing a web
service application that references a DLL component written in C# 2.0.
The component has its own config file which contains settings related
to business logic coded in that component. I can reference and load
the component but unable to read load the custom config file of that
component. I know that the same thing is possible if my host
application is any Exe application and using
"ExeConfigurationFileMap", "OpenMappedExeConfiguration" I can read
configuration file other than app.config but the same is not possible
if I use "WebConfigurationFileMap" and "OpenMappedWebConfiguration".
Using both these we can only define the mappings b/w virtual and
physical directories but can't read config file other than
web.config.

string dummyVirtualPath = "/test_web_2005";
string physicalPath = @"C:\Inetpub\wwwroot
\test_web_2005\Bin";
string configFileName =
System.IO.Path.GetFileName(assembly.CodeBase) + ".config";
WebConfigurationFileMap map = new WebConfigurationFileMap();
map.VirtualDirectories.Add(dummyVirtualPath, new
VirtualDirectoryMapping(physicalPath, true));
Configuration config =
WebConfigurationManager.OpenMappedWebConfiguration (map,
dummyVirtualPath);

Is there any other idea to implement the same. Thanks in advance.

Regards
Irfan

Apr 17 '07 #2

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

Similar topics

1
by: Ray Stevens | last post by:
I have a dotnet wrapper service running on a service that calls one of our custome components. I would like to read the appsettings section from a config file, but because this is a class file...
8
by: Martin Eyles | last post by:
Hi, I have a configuration file I made in xml which I am using to name a database server. (this way I can deploy my web page on various servers, and just change this file to make it work)....
2
by: news.microsoft.com | last post by:
Hi After conducting a several searches, I wasn't sure where to post this question. So my apologiesbefore hand for double posting this and possibly posting to the wrong forum(s). Okay, I have...
3
by: cuneyt | last post by:
Hi I am working on a class that reads parameter values from a configuration file and inserts them into a hash. There are many good dimplementations of this on the Web. What I would like to do,...
3
by: Søren M. Olesen | last post by:
Hi I've created a Class library (myClasses.dll), and added a settings.settings to it using designer. However when I use this class library, it doesn't seem to read the settings...
3
by: Waldy | last post by:
Hi there, I added an app.config file to a .DLL project, but the code does not read the values from it. I understand that these files are intended for executables rather than .dlls. What is the...
10
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...
2
by: M Irfan | last post by:
Recently I have started working in .NET 2.0. I am developing a web service application that references a DLL component written in C# 2.0. The component has its own config file which contains...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.