473,386 Members | 1,715 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.

ClassLibrary.DLL and app.config files


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 during
runtime, it run within the context of another main application that has its
own app.config file (am I correct?)

My main question is how can I control a ClassLibrary.DLL to read its own
app.config or the main application's app.config file?

Thank you,

Alan
Nov 17 '05 #1
7 21120
Alan,

Class libraries can not have their own app config files (unless they are
the entry points, in some cases). They defer to the application
configuration file of the executing application.

You should place your configuration section in your app.config file for
the application that uses the library. This is in the case where different
applications can use the library in a different manner and you want to
configure that in the app.config file.

If the settings do not change across application instances, then you
should probably just have a file in the directory where the class library is
installed and read from that.

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

"A.M-SG" <al******@newsgroup.nospam> wrote in message
news:e8**************@TK2MSFTNGP14.phx.gbl...

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 during
runtime, it run within the context of another main application that has
its own app.config file (am I correct?)

My main question is how can I control a ClassLibrary.DLL to read its own
app.config or the main application's app.config file?

Thank you,

Alan

Nov 17 '05 #2
Thank you for help.
If the settings do not change across application instances, then you
should probably just have a file in the directory where the class library
is installed and read from that.
Do you mean to have an app.config file in the ClassLib directory ? or a
custom XML file to store setting?

Thank you again,
Alan


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl... Alan,

Class libraries can not have their own app config files (unless they
are the entry points, in some cases). They defer to the application
configuration file of the executing application.

You should place your configuration section in your app.config file for
the application that uses the library. This is in the case where
different applications can use the library in a different manner and you
want to configure that in the app.config file.

If the settings do not change across application instances, then you
should probably just have a file in the directory where the class library
is installed and read from that.

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

"A.M-SG" <al******@newsgroup.nospam> wrote in message
news:e8**************@TK2MSFTNGP14.phx.gbl...

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 during
runtime, it run within the context of another main application that has
its own app.config file (am I correct?)

My main question is how can I control a ClassLibrary.DLL to read its own
app.config or the main application's app.config file?

Thank you,

Alan


Nov 17 '05 #3
Hi,

I assume that a ClassLibrary.DLL can have a app.config file, but during
runtime, it run within the context of another main application that has
its own app.config file (am I correct?)

Wrong, they do not.

I have a similar situation, I have a DLL that is a command for ArcGIS and
need to store some config values, even more, this values should be
particular to each users.
I create a folder under ApplicationData using :
System.Environment.GetFolderPath(Environment.Speci alFolder.ApplicationData);

There I store my config file.
For the config you have several options, if you prefer something like the
"regular" config, you could use a Hashtable and serialize it, then you can
use it like Config["Key"] = value;
Or as I did, I only have 5 values, so I used instead a text file in the form
key=value , I open, read and parse it and I make available those variables
as static properties.
I don't need to save them back, so it's even easier.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 17 '05 #4
Hi Alan,

We can not apply an app.config file to the class library dll. Because just
as the name implied, this configuration file is for the application wide.

I think what "Nicholas Paldino [.NET/C# MVP]" sugggested is to place the
class library configuration sections into the app.config file where your
application is in. Then your class library code can read the configuration
without any problem.

If you still want a customized config file for class library so that we
need not copy the config information to all the applications using the dll,
I think we have to store the configuration information in a XML file, then
use System.Xml namespace classes to read this XML config file.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #5
Hi Alan,

Does my reply make sense to you? If you still have any concern, please feel
free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #6
Hi Jeffrey,

Yes, your reply helped me.

Thanks alot,
Alan

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:gR**************@TK2MSFTNGXA01.phx.gbl...
Hi Alan,

Does my reply make sense to you? If you still have any concern, please
feel
free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #7
It is my pleasure to help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #8

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

Similar topics

4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
0
by: Will Waggoner | last post by:
Ok, I've been hung up on this issue for quite some time now and I would like some help in getting it to work. I think this may be a setup issue but I'd like to ask your eminences first. Here's...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
1
by: PEACEMAKER | last post by:
I'm writing a custom config file for my classlibrary dll. However when I try to load the config file the directory it points to is the folder of the application that called the dll. Is there a way...
3
by: Rene | last post by:
I notice that VS lets you choose to create a WindowsControlLibrary and ClassLibrary, I created a class library and then added a user control and it let me do that. I am assuming that the opposite...
1
by: Alex Kid | last post by:
I have a Client/server software and in a Server Class Library. I have need to save of the configuration data(App.Config) but I know that what is not possibile.In alternative could use? I would...
2
by: Poobalam | last post by:
Hi, I just got VS.NET 2005. It has a new template called WebControlLibrary. I normally use ClassLibrary to build my business logic and use that dll into ASP.NET project. However I'm assuming...
7
by: Stefan | last post by:
Hi! I´m creating a classlibrary project. The output will be a dll. This dll will have to read some settings from some kind of config-file. Normally, when creating a standard .exe-program I use...
1
by: Lupus | last post by:
Hi folks, I've created a class library, compiled as a .DLL-file to support my ASP.NET webapplication. My .NET-application has some parameters (ie. SQL connection string) stored in the web.config...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.