[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

System Service Question

GaryDean

11/13/2008 10:19:00 PM

I'm writing code currently inside a Windows forms application that will be
ported to the form of a system service. I'm aware of many of the attributes
of a service such as not interacting with a user, etc. But where does a
system service keep their settings? There seems to be no .config file to
put an appsettings or connectionstrings into. I know I could put settings
in constants or in a text file somewhere on disk but I'm looking for best
practices.
Thanks,
Gary


3 Answers

jialge

11/14/2008 9:05:00 AM

0

Hello Gary,

From your post, my understanding on the issue is that you want to know a
practical way to store app settings in a windows service.

Actually, you can add a config file, commonly named as "App.config" into
your windows service project. The following is a snippet of the config
file. You may add what you want, including appSetting and
connectionStrings. After the build, the config file will be named as
"xxx.exe.config".

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings></appSettings>
<connectionStrings></connectionStrings>
</configuration>

You may use the following steps to add a config file in your windows
service project.
1. Right click the project, select Add->New Item¡­
2. Select the "Application Configuration File" in the "Add New Item" dialog

Commonly, the configuration file exists in the same folder with windows
service file. Of course, you may put the configuration file to other
folder. In this scenario, you must use the method
"ConfigurationManager.OpenMappedExeConfiguration" to tell the windows
service where its configuration is located. You may take the following
codes as reference:
static void Main(string[] args)
{
//other code
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = args[0];
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(
fileMap, ConfigurationUserLevel.None);
//other code
}

More examples for your references:
http://www.aspfree.com/c/a/C-Sharp/Creating-a-Windows-Service-with...
oncluded/
http://www.15seconds.com/issue/...

Regarding the built-in attributes of services (e.g. not interacting with a
user), their setting information is stored in the registry. You may find
these information in the following subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Please let me know the information above so that I can provide further
assistance on this problem. I am looking forward to your reply.

Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#not....

MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa9...
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

JerryD\(upstateNY\)

5/10/2012 8:54:00 PM

0

Gary wrote Where does the other $475 billion go ?

"Jim_Higgins" wrote in message There are the ongoing cost overruns,
inadequately thought out "Wunderwaffe" like the F-22, F-35,
Navy LCS ships etc. That eats up a LOT of money and fattens
defense contractors and Congressmen.<<<<

Just another example, that the federal government can't run ANYTHING, well.
Private companies get people who know what they are doing to run their
companies.
The government gets relatives and big political donors to run things.
And the democrats think government run health care will be run well and cost
effective.

--
JerryD(upstateNY)



Gary

5/10/2012 9:02:00 PM

0

On Thu, 10 May 2012 16:54:23 -0400, "JerryD\(upstateNY\)"
<jerryd@rochester.rr.com> wrote:

>Gary wrote Where does the other $475 billion go ?
>
>"Jim_Higgins" wrote in message There are the ongoing cost overruns,
> inadequately thought out "Wunderwaffe" like the F-22, F-35,
> Navy LCS ships etc. That eats up a LOT of money and fattens
> defense contractors and Congressmen.<<<<
>
>Just another example, that the federal government can't run ANYTHING, well.
>Private companies get people who know what they are doing to run their
>companies.
>The government gets relatives and big political donors to run things.
>And the democrats think government run health care will be run well and cost
>effective.

The government runs things very well. Look at the Army. Look at
prisons. Look at Social Security. Look at Medicare. Look at the
200 year old Post Office.

It's when these damn crooks in Congress demand the government hire
"civilian contractors" to do what the government can do itself, is
when everything screws up.