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(C onfigurationSet tngs.AppSetting s["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 1830
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*******@disc ussions.microso ft.com> wrote in message
news:2B******** *************** ***********@mic rosoft.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(C onfigurationSet tngs.AppSetting s["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*******@disc ussions.microso ft.com> wrote in message news:2B******** *************** ***********@mic rosoft.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(C onfigurationSet tngs.AppSetting s["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 I establish a Publisher
Policy file. So I have that.
I have built a Windows app for the same product. This app prompts the user
for a path to a third party assembly that depends on my assembly. It opens
the third party assembly (Assembly.Load)...
|
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 advantages of XML config files are promoted;
1. The .NET framework provides built-in support for reading
application configuration data from .config files very easily
2. Using these files makes it possible to deploy an application using
|
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 I
thought I had solved. For example, let's say I wanted to do this:
http://myserver/appdir/mywinformapp.exe?username=joe&age=12
Providing code access security permissions allow it, mywinformapp.exe
is downloaded to the client and launches...
|
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 (in order to have the tree view, multi bar
controls).
When I make the compilation and the execution, I obtain then the next error:
"
| |
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 write the information about user
name, filename upload, filesize, date and time of uploading into the log
file. (The name of the log file is constructed by Current Year and Current
Month in my program). Is there any problems with writing into the...
|
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 specify in the config file all of the pages that
require a user to login otherwise the page will redirect if the user is
not logged in.
config.php looks like this:
----------------------
|
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 out how to access the two
settings. I need to be able to get the data out of the settings. And update
them at a later point as well. I have tried all sorts of things.
Dim CurReceipt As Integer =...
|
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
configured. As a testing purpose I have build a client application which
contains app.config files with paramters for this libary. Everything works as
expected.
Now the question is that I do not want to place library parmeters with the
|
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.
As for where to store it, I use os.path.expanduser("~") to find the
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |