Hi,
I am building a class library and want to store a connection string in a
configuration file.
I've read around and it appears that this is not possible because "by
design, class libraries don't have their own config file - they read the
config files from the application they are housed in, such as a WinForm app
or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR 12 2235
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Presumeably the code is only of real use when used in a Windows/Web app so
use the app/web.config file of the application that is using your code
library
and define the connection string there? Use the registry?
HTH
AP
Nottingham - UK
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Presumeably the code is only of real use when used in a Windows/Web app so
use the app/web.config file of the application that is using your code
library
and define the connection string there? Use the registry?
HTH
AP
Nottingham - UK
Your .dll (read .NET code library) should NOT be dependent upon anything.
If one of the objects you expose needs a connection string to work, you
should provide a property accessor to enable the user of your library to
get/set the string.
A .dll should operate as a "black box", i.e. you know what you need to put
in and you know what you expect to get out; anyone using your library does
not want to have to remember to copy the config file too (even you won't want
to do that)
--
Of all words of tongue and pen, the saddest are: "It might have been"
Bill.Richards @ greyskin .co .uk http://greyskin.co.uk
"CodeRazor" wrote: Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
Your .dll (read .NET code library) should NOT be dependent upon anything.
If one of the objects you expose needs a connection string to work, you
should provide a property accessor to enable the user of your library to
get/set the string.
A .dll should operate as a "black box", i.e. you know what you need to put
in and you know what you expect to get out; anyone using your library does
not want to have to remember to copy the config file too (even you won't want
to do that)
--
Of all words of tongue and pen, the saddest are: "It might have been"
Bill.Richards @ greyskin .co .uk http://greyskin.co.uk
"CodeRazor" wrote: Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
Hi,
You can do a couple of things:
1- Force the calling app to initialize it, this works better in an escenario
like yours, where only a couple of values needs to be defined.
2- Provide a config file and parse it yourself, depending of the requirement
this can be stored in the user's application data directory or the
installed location,
3- You can always store info in your old friend , the registry :) ,
OT: I just did a backup of my registry and it 's over 120 MB !!! and this
is computer has less than one year of use
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
Hi,
You can do a couple of things:
1- Force the calling app to initialize it, this works better in an escenario
like yours, where only a couple of values needs to be defined.
2- Provide a config file and parse it yourself, depending of the requirement
this can be stored in the user's application data directory or the
installed location,
3- You can always store info in your old friend , the registry :) ,
OT: I just did a backup of my registry and it 's over 120 MB !!! and this
is computer has less than one year of use
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
"billr" <bi***@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com... Your .dll (read .NET code library) should NOT be dependent upon anything.
Aren't you making it dependent on the caller setting a connection string? If one of the objects you expose needs a connection string to work, you should provide a property accessor to enable the user of your library to get/set the string.
The question that needs to be answered is, is the connection string part of
the blackness (of the black box) or should it be exposed to the user? Does
the caller even know that a database is used by the dll? A .dll should operate as a "black box", i.e. you know what you need to put in and you know what you expect to get out; anyone using your library does not want to have to remember to copy the config file too (even you won't want to do that)
I don't see a difference between requiring the user to copy a configuration
file and requiring them to set a connection string property. "CodeRazor" wrote:
Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
"billr" <bi***@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com... Your .dll (read .NET code library) should NOT be dependent upon anything.
Aren't you making it dependent on the caller setting a connection string? If one of the objects you expose needs a connection string to work, you should provide a property accessor to enable the user of your library to get/set the string.
The question that needs to be answered is, is the connection string part of
the blackness (of the black box) or should it be exposed to the user? Does
the caller even know that a database is used by the dll? A .dll should operate as a "black box", i.e. you know what you need to put in and you know what you expect to get out; anyone using your library does not want to have to remember to copy the config file too (even you won't want to do that)
I don't see a difference between requiring the user to copy a configuration
file and requiring them to set a connection string property. "CodeRazor" wrote:
Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
I have always felt the class libraries (or more specifically non ui layers)
should have config information passed into them via parameters instead
of having their own config files. I'll assume for the sake of argument
that you have a good reason for doing. So, no need to explain it here.
Here's how to duplicate the System.Configuration.AppSettings class
to be a specific config file. This sample talks about the .NET Compact
Framework
but is applicable to anything. http://www.eggheadcafe.com/articles/...app_config.asp
--
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com. http://www.eggheadcafe.com/forums/merit.asp
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
I have always felt the class libraries (or more specifically non ui layers)
should have config information passed into them via parameters instead
of having their own config files. I'll assume for the sake of argument
that you have a good reason for doing. So, no need to explain it here.
Here's how to duplicate the System.Configuration.AppSettings class
to be a specific config file. This sample talks about the .NET Compact
Framework
but is applicable to anything. http://www.eggheadcafe.com/articles/...app_config.asp
--
Robbe Morris - 2004/2005 Microsoft MVP C#
Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com. http://www.eggheadcafe.com/forums/merit.asp
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Hi,
I am building a class library and want to store a connection string in a configuration file.
I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
So, with that in mind, is there an alternative solution?
Many thanks,
CR
Thankyou everyone, your responses were really useful.
Cheers,
CodeRazor
Thankyou everyone, your responses were really useful.
Cheers,
CodeRazor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Maxim Khesin |
last post by:
I want to have a config file with my python proggie, satisfying the
following requirements:
1) support key->(value, default)
2) simple and intuitive to read and edit
3) easyly readable into a...
|
by: Simon |
last post by:
Hi everyone,
I really need help with the following:
It's common in app development to create numerous projects under one
solution that as a whole combine to become your final application. For...
|
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...
|
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...
|
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...
|
by: kalyankp78 |
last post by:
Hi,
I have a question about config files. I have the following in my
application..
1. ASP.NET web application with a web.config
2. C# class library (BL and DAL) with an App.config
3. Two...
|
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...
|
by: =?Utf-8?B?Y2FsZGVyYXJh?= |
last post by:
Dear all,
I am building a set of libraries working in a n tiers architecture
Some of those libraries use common configuration settings like the database
connection string and some others.
I...
|
by: Bill McCormick |
last post by:
<!-- When deploying the service library project, the content of the
config file must be added to the host's app.config file.
System.Configuration does not support config files for libraries. -->
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |