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 classes are used by both the
application and the service. I have stored the database connection string in
an app.config file located in the class library project.
Everything was working fine on my dev box, but when I migrated to the QA
box, I started getting a "connection string not initialized" error. When I
hard code the connection string in each of the class files, everything works
fine, which leads me to believe that the problem is that the app.config file
is not being read. The code I'm using in each of my class files is:
SqlConnection conn = new
SqlConnection(ConfigurationSettngs.AppSettings["whitney"]);
Questions: since the class library is the only project that connects to the
database, is it the only project that should have an app.config file with the
connection string? Do I need to explicitly add the app.config file to my
installer project? What could I be doing wrong?
Thanks in advance for your help!
Brian 2 1805
nope.
Your class library does not have a config file and it will not have one. I
have no idea how you've been access a config file in testing, but in
production, you will use the config file for the exe, not the dll.
Therefore, both your windows app and your windows service will need to
either have the connection string, or refer to a config file that does.
I addressed the issue of having a config file for a dll in a recent blog
posting. It may help... http://blogs.msdn.com/nickmalik/arch...25/270420.aspx
--- Nick
"bmcelhany" <bm*******@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com... 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 classes are used by both the application and the service. I have stored the database connection string
in an app.config file located in the class library project.
Everything was working fine on my dev box, but when I migrated to the QA box, I started getting a "connection string not initialized" error. When I hard code the connection string in each of the class files, everything
works fine, which leads me to believe that the problem is that the app.config
file is not being read. The code I'm using in each of my class files is: SqlConnection conn = new SqlConnection(ConfigurationSettngs.AppSettings["whitney"]);
Questions: since the class library is the only project that connects to
the database, is it the only project that should have an app.config file with
the connection string? Do I need to explicitly add the app.config file to my installer project? What could I be doing wrong?
Thanks in advance for your help!
Brian
Thanks Nick,
I took the config file out of the library project, put a copy in both the
windows app and service projects, and everything works like a charm. Not sure
why it was working on my dev box...
Thanks!
"Nick Malik" wrote: nope.
Your class library does not have a config file and it will not have one. I have no idea how you've been access a config file in testing, but in production, you will use the config file for the exe, not the dll. Therefore, both your windows app and your windows service will need to either have the connection string, or refer to a config file that does.
I addressed the issue of having a config file for a dll in a recent blog posting. It may help... http://blogs.msdn.com/nickmalik/arch...25/270420.aspx
--- Nick "bmcelhany" <bm*******@discussions.microsoft.com> wrote in message news:2B**********************************@microsof t.com... 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 classes are used by both the application and the service. I have stored the database connection string in an app.config file located in the class library project.
Everything was working fine on my dev box, but when I migrated to the QA box, I started getting a "connection string not initialized" error. When I hard code the connection string in each of the class files, everything works fine, which leads me to believe that the problem is that the app.config file is not being read. The code I'm using in each of my class files is: SqlConnection conn = new SqlConnection(ConfigurationSettngs.AppSettings["whitney"]);
Questions: since the class library is the only project that connects to the database, is it the only project that should have an app.config file with the connection string? Do I need to explicitly add the app.config file to my installer project? What could I be doing wrong?
Thanks in advance for your help!
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peter Blum |
last post by:
I have built an assembly (dll) from which I expect third parties to
subclass. As a result, when my assembly has a version change, it will cause
any third party assembly based on it to break unless...
|
by: Tim Blizard |
last post by:
I know this topic has been discussed before but I couldn't find any
thread more recent than about 18 months and was interested in what
conclusions people had come to recently.
Invariably 3...
|
by: 3f |
last post by:
Hello;
We have made a web application that people can download from our web site
and installed on:
Windows XP
Windows 2000 Professional
Windows 2003 Server
Windows 2000 Server
|
by: JDeats |
last post by:
I have a WinForms based application that I'm launching over http
(Microsoft's buzz word for this is aparently "SmartClient"). I had an
issue trying to get parameters passed in through the URL that...
|
by: Cui |
last post by:
Hello,
I make an application in ASP.NET (using VB.NET and some web services). For
my needs, I use also the SQL DMO library (with the SQL DMO.interop assembly)
and the Microsoft Web UI controls...
| |
by: HNguyen |
last post by:
Hi,
I have a Web application in ASP.NET. My Application allows the users upload
files into the server after checking their user names and passwords. For
each transaction, the Web program will...
|
by: Greg Scharlemann |
last post by:
I thought I had a workable approach to specifing which pages required a
redirect in a config file, but it appears the way I'm attempting to do
it is not going to work.
The idea is that I can...
|
by: Stacey |
last post by:
I am using Visual Studio 2005, creating a VB.NET program. I am have created
a settings file and two settings in the file. The section that it created
in my app.config is below. I can not figure...
|
by: =?Utf-8?B?Y2FsZGVyYXJh?= |
last post by:
Dear all,
I am developing a multi tiers application and actually responsible of
delivering the buines logic library.
That buisnes logic library will need some parameters to be suitebale...
|
by: Nick Craig-Wood |
last post by:
Lance Gamet <lance@gamet.comwrote:
I've found
http://docs.python.org/lib/module-ConfigParser.html
To be easy to use and built in. It makes human readable / editable
..ini - like files.
...
|
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,...
| |
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...
|
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,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |