473,320 Members | 2,024 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,320 software developers and data experts.

config file for Class Library?

Say, you have a C# project called "MyClassLib". So the project would
generate MyClassLib.dll. I want MyClassLib.dll to get some setting
information, so I thought of creating MyClassLib.dll.config. This obviously
doesn't work cuz it doesn't seem to be supported. Alternative solution would
be to create your own XML file and a class that reads it... What I'm
wondering is if there is any way that's supported by .NET framework....

TIA
Nov 15 '05 #1
3 7416
Hayato,

It is not currently supported in the framework. You can try and access
the information in the .config file for the application (through the current
mechanism), or you can code your own mechanism. Using XML serialization, or
the SOAP formatter to serialize an object which has the properties you need
to access would probably be the easiest way to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Hayato Iriumi" <hi*****@hotmail.com> wrote in message
news:OR*************@tk2msftngp13.phx.gbl...
Say, you have a C# project called "MyClassLib". So the project would
generate MyClassLib.dll. I want MyClassLib.dll to get some setting
information, so I thought of creating MyClassLib.dll.config. This obviously doesn't work cuz it doesn't seem to be supported. Alternative solution would be to create your own XML file and a class that reads it... What I'm
wondering is if there is any way that's supported by .NET framework....

TIA

Nov 15 '05 #2
Hi,

The dll will always take configuration setting
information of the surrogate i.e.,

If MyClassLib.dll is used by MyProject.exe then
MyClassLib.dll will read the configuration setting from
MyProject.exe.config.

If you have deployed your component MyClassLib.dll in
COM+ then it reads config settings from
dllhost.exe.config since dllhost.exe is the surrogate.

Hope this helps...

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
Say, you have a C# project called "MyClassLib". So the project wouldgenerate MyClassLib.dll. I want MyClassLib.dll to get some settinginformation, so I thought of creating MyClassLib.dll.config. This obviouslydoesn't work cuz it doesn't seem to be supported. Alternative solution wouldbe to create your own XML file and a class that reads it... What I'mwondering is if there is any way that's supported by .NET framework....
TIA
.

Nov 15 '05 #3
Hi, Madhu.
Yeah, that's what I just found out. I was able to get the config values from
the MyExe.exe.config. I guess this is because the DLL runs within
MyExe.exe's AppDomain.

Thanks!

"Madhu [MVP]" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Hi,

The dll will always take configuration setting
information of the surrogate i.e.,

If MyClassLib.dll is used by MyProject.exe then
MyClassLib.dll will read the configuration setting from
MyProject.exe.config.

If you have deployed your component MyClassLib.dll in
COM+ then it reads config settings from
dllhost.exe.config since dllhost.exe is the surrogate.

Hope this helps...

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
Say, you have a C# project called "MyClassLib". So the

project would
generate MyClassLib.dll. I want MyClassLib.dll to get

some setting
information, so I thought of creating

MyClassLib.dll.config. This obviously
doesn't work cuz it doesn't seem to be supported.

Alternative solution would
be to create your own XML file and a class that reads

it... What I'm
wondering is if there is any way that's supported

by .NET framework....

TIA
.

Nov 15 '05 #4

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

Similar topics

2
by: bmcelhany | last post by:
Hi all, I have a solution with 4 projects: a class library, a windows app, a windows service, and an installer project. The class library handles all communication with the database and its...
4
by: grs | last post by:
Can a class library have a app.config file. Reason for asking is that the microsoft application blocks all read from myApp.exe.config. How can you use the application blocks if you do not have an...
7
by: A.M-SG | last post by:
Hi, We have a class library application that needs to read some application settings from it's own app.config file. I assume that a ClassLibrary.DLL can have a app.config file, but...
1
by: Erik J Sawyer | last post by:
Is there any documentation on using config files with multiple assemblies? For example, I have a class library installed to the GAC. This is then used in several ASPX pages. If the class...
10
by: bradtm | last post by:
So I have this hierarchy: + Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application |
16
by: Timm | last post by:
I'm trying to use ASP objects (basically formed and populated based on Web.Config settings) and I want to use them in a different non-asp program with minimal reprogramming. So, my question is how...
4
by: WT | last post by:
My web site is using a library created in a separate project. VS 2005 has created for it an App.config file. The library is included as a refernce in my web site. When I copied my web site to it's...
9
by: Dick | last post by:
Visual Studio saves lots of values in the project's app.config file (connection strings for datasets, My.settings, etc.), but as far as I can see, if the project is in the middle teir, these values...
3
by: Fernando Chilvarguer | last post by:
Hello! I created a Class Library project in VS2005. Then, using VS, I was able to add a connection string to the project settings, which automaticaly created an app.config file for me. If I try...
6
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...
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...
1
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.