.NETGURU
Win2k Service Not Reading appSettings in Web.config
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-services' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Al B -DN
-- Copied from [aspngfreeforall] to [ngfx-services] by Marcie Jones <Click here to reveal e-mail address> --

MODERATOR: Please forward to the appropriate forum, I'm not sure where
this one goes...thanks!
==============

Hi there, my situation is this:

1) I have a Win2k Service running (built w/VS.NET) that is using the
FileSystemWatcher
2) This service imports the entire namespace associated with my web
application
3) This service makes a call to a sub that opens a database and makes
changes to it
4) The connection string is defined as a Key located within
<appSettings> in Web.config
5) My service doesn't seem to be able to access this connection string
and errors out

SO...Is there any way to insure that my service will get this
information out of Web.config? If not, what might be some other options
for storing the connection string?

Thanks much!
Al

-ALB-

Reply to this message...
 
    
Douglas Reilly (VIP)

The service will not read the Web.Config file using appSettings. =20

You could manually load up the Web.Config file as an XML file and get =
the information you need, or perhaps better, you could use a seperate =
XML file or even the registry (I have some WinForms programs that use =
the registry classes, and they work pretty well).

----- Original Message -----
From: "Al B -DN" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Wed, 10 Apr 2002 16:18:36 -0700
Subject: Win2k Service Not Reading appSettings in Web.config

-- Copied from [aspngfreeforall] to [ngfx-services] by Marcie Jones =
<Click here to reveal e-mail address> --

MODERATOR: Please forward to the appropriate forum, I'm not sure where
this one goes...thanks!
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Hi there, my situation is this:

1) I have a Win2k Service running (built w/VS.NET) that is using the
FileSystemWatcher
2) This service imports the entire namespace associated with my web
application
3) This service makes a call to a sub that opens a database and makes
changes to it
4) The connection string is defined as a Key located within
<appSettings> in Web.config
5) My service doesn't seem to be able to access this connection string
and errors out

SO...Is there any way to insure that my service will get this
information out of Web.config? If not, what might be some other options
for storing the connection string?

Thanks much!
Al

-ALB-

Reply to this message...
 
    
Jeff Widmer
Al,
The web.config file is for configuration settings for your web application.
The .Net service, which is just an executable, will have it's own config
file. For the service the file would be called app.config. You can put the
connection string in this file and access it through the
system.configuration.configurationsettings class.

If you have a single database component that you call from both your web
application and your service, when the DB component is called from the web
application the connection string from the web.config file will be used.
When the DB component is called from the .Net Service, the app.config file
will be used.

Also note that if you are using vs.net, you can add the app.config to your
project but then on compiling your service, the app.config file is copied to
your bin directory and renamed to [appname].exe.config. This is the one
that will be used, so if you ever change an item using notepad, make sure
you change this file and not the app.config file only.

Hope this helps,
-Jeff

-----Original Message-----
From: Al B -DN [mailto:Click here to reveal e-mail address]
Sent: Wednesday, April 10, 2002 4:19 PM
To: ngfx-services
Subject: [ngfx-services] Win2k Service Not Reading appSettings in
Web.config

-- Copied from [aspngfreeforall] to [ngfx-services] by Marcie Jones
<Click here to reveal e-mail address> --

MODERATOR: Please forward to the appropriate forum, I'm not sure where
this one goes...thanks!
==============

Hi there, my situation is this:

1) I have a Win2k Service running (built w/VS.NET) that is using the
FileSystemWatcher
2) This service imports the entire namespace associated with my web
application
3) This service makes a call to a sub that opens a database and makes
changes to it
4) The connection string is defined as a Key located within
<appSettings> in Web.config
5) My service doesn't seem to be able to access this connection string
and errors out

SO...Is there any way to insure that my service will get this
information out of Web.config? If not, what might be some other options
for storing the connection string?

Thanks much!
Al

-ALB-

| [ngfx-services] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-services.asp = JOIN/QUIT

Reply to this message...
 
    
Al B -DN
This worked perfectly, Jeff...thanks much for the feedback!
Al

-----Original Message-----
From: Jeff Widmer [mailto:Click here to reveal e-mail address]
Sent: Wednesday, April 10, 2002 5:23 PM
To: ngfx-services
Subject: [ngfx-services] RE: Win2k Service Not Reading appSettings in
Web.config
Importance: High

Al,
The web.config file is for configuration settings for your web
application. The .Net service, which is just an executable, will have
it's own config file. For the service the file would be called
app.config. You can put the connection string in this file and access
it through the system.configuration.configurationsettings class.

If you have a single database component that you call from both your web
application and your service, when the DB component is called from the
web application the connection string from the web.config file will be
used. When the DB component is called from the .Net Service, the
app.config file will be used.

Also note that if you are using vs.net, you can add the app.config to
your project but then on compiling your service, the app.config file is
copied to your bin directory and renamed to [appname].exe.config. This
is the one that will be used, so if you ever change an item using
notepad, make sure you change this file and not the app.config file
only.

Hope this helps,
-Jeff

-----Original Message-----
From: Al B -DN [mailto:Click here to reveal e-mail address]
Sent: Wednesday, April 10, 2002 4:19 PM
To: ngfx-services
Subject: [ngfx-services] Win2k Service Not Reading appSettings in
Web.config

-- Copied from [aspngfreeforall] to [ngfx-services] by Marcie Jones
<Click here to reveal e-mail address> --

MODERATOR: Please forward to the appropriate forum, I'm not sure where
this one goes...thanks! ==============

Hi there, my situation is this:

1) I have a Win2k Service running (built w/VS.NET) that is using the
FileSystemWatcher
2) This service imports the entire namespace associated with my web
application
3) This service makes a call to a sub that opens a database and makes
changes to it
4) The connection string is defined as a Key located within
<appSettings> in Web.config
5) My service doesn't seem to be able to access this connection string
and errors out

SO...Is there any way to insure that my service will get this
information out of Web.config? If not, what might be some other options
for storing the connection string?

Thanks much!
Al

-ALB-

| [ngfx-services] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-services.asp = JOIN/QUIT

| [ngfx-services] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-services.asp = JOIN/QUIT

Reply to this message...
 
    
Al B -DN
Hi Douglas,

I like the registry as an option...however, that's a bit out of my
skill-range for the moment! <grin> Pulling the data out of the
web.config file using XML is a great plan, and I think I might
ultimately go that route... That way the connection string is only
stored in one location (not multiple).

Thanks much for the feedback!
Al

-----Original Message-----
From: Douglas Reilly [mailto:Click here to reveal e-mail address]
Sent: Wednesday, April 10, 2002 4:57 PM
To: ngfx-services
Subject: [ngfx-services] Re: Win2k Service Not Reading appSettings in
Web.config
Importance: High

The service will not read the Web.Config file using appSettings.

You could manually load up the Web.Config file as an XML file and get
the information you need, or perhaps better, you could use a seperate
XML file or even the registry (I have some WinForms programs that use
the registry classes, and they work pretty well).

----- Original Message -----
From: "Al B -DN" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Wed, 10 Apr 2002 16:18:36 -0700
Subject: Win2k Service Not Reading appSettings in Web.config

-- Copied from [aspngfreeforall] to [ngfx-services] by Marcie Jones
<Click here to reveal e-mail address> --

MODERATOR: Please forward to the appropriate forum, I'm not sure where
this one goes...thanks! ==============

Hi there, my situation is this:

1) I have a Win2k Service running (built w/VS.NET) that is using the
FileSystemWatcher
2) This service imports the entire namespace associated with my web
application
3) This service makes a call to a sub that opens a database and makes
changes to it
4) The connection string is defined as a Key located within
<appSettings> in Web.config
5) My service doesn't seem to be able to access this connection string
and errors out

SO...Is there any way to insure that my service will get this
information out of Web.config? If not, what might be some other options
for storing the connection string?

Thanks much!
Al

-ALB-

| [ngfx-services] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-services.asp = JOIN/QUIT

Reply to this message...
 
 
System.IO.FileSystemWatcher




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification