473,320 Members | 2,107 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.

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 21112
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.