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

Reading config file other than web.config

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
2 7401
See my response in the C# newsgroup. Actually, this is the best group for the
question, I just saw that one first.
Peter

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


"M Irfan" wrote:
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
On Apr 17, 6:02 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
See my response in the C# newsgroup. Actually, this is the best group for the
question, I just saw that one first.
Peter

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

"M Irfan" wrote:
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 ownconfigfilewhich contains settings related
to business logic coded in that component. I can reference and load
the component but unable to read load the customconfigfileof 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
configurationfileotherthanapp.configbut 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 readconfigfileotherthan
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));
Configurationconfig=
WebConfigurationManager.OpenMappedWebConfiguration (map,
dummyVirtualPath);
Is there anyotheridea to implement the same. Thanks in advance.
Regards
Irfan
Hi Peter,

Thanks for the response. I know that I can use web.config but I dont
want to use that. The component will be reponsible for sending data to
multiple partners and at run time partner specific object would be
instantiated using Reflection. For the time being I think its should
use a custom config reader. Design wise I believe it would be good if
objects and their configurations are laoded dynamically without being
depended on web.config.

Regards
Irfan.

Apr 18 '07 #3

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...
1
by: M Irfan | last post by:
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...
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...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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,...

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.