Re: Configuration data for a Windows Service



More good information. Unfortunately, not an answer to my question. :)

The service will definitely use a configuration file for at least some of
its data. Whether or not that points to a separate configuration file that
stores the information for the pluggable objects or contains the details for
the pluggable objects itself is still on the table.

But, my question is really where should I put the auxillary files?
Obviously, the application's configuration file goes with the the PE. But,
the configuration files containing the additional details could go any number
of places. If my hosting application was a standard Windows Forms
application then it wouldn't be a problem. The user settings would get
stored on a per user basis. That doesn't really apply to a Windows Service
running as Network Service.

I hope this helps describe my question:

C:\Program Files\...\MyService.exe
C:\Program Files\...\MyService.exe.config

GAC\PluggableObjects1.dll
GAC\PluggableObjects2.dll

???\PluggableObjects1.xml
???\PluggableObjects2.xml

In this instance MyService.exe.config might contain entries like this:

<PluggableObject Id="1" AssemblyName="PluggableObjects1.dll ..."
ConfigFile="???\PluggableObjects1.xml" />
<PluggableObject Id="2" AssemblyName="PluggableObjects2.dll ..."
ConfigFile="???\PluggableObjects2.xml" />

So what it boils down to is the best folder to fill in for the "???" for
each pluggable object? Isolated storage wouldn't work, because the files
need to be accessible from a user context when being modfiied through an MMC
snap-in. Program Files is obviously not a good choice. I don't like the
idea of arbitrary folders off the root of the hard drive although I could be
convinced that's the best choice. (I'm also not suggesting that this be the
only option, but rather the default expected location.)

"sloan" wrote:


Then you'll have to add logic which says "here is where I'm going to get my
config file".

One way would be to add a config section to the main app.config (of the
windows service) and then say:


<MyConfigFileLocations>
<file ForAssembly="mycompany.myapplication.dll"
Location="mycompany.myapplication.config" />

</MyConfigFileLocations>

Something like that.

You need ~~some~~ kind of rule that says where the config file is.

It can either be:
in the app.config of the hosting application
in the same directory as the hosting application
in the directory of where the .dll is ( the url I gave)
in a specific place, and you tell it where it is. (the solution above).


If you want GAC ability, but have multiple instantiations of it, then you'll
need to do something like I describe above.


If you need an example of how to create your own config section, then check
this:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry

it has nothing to do with your problem, but shows how create objects from a
well defined (yours) xml schema, which resides in the app.config file.

You want to see how the EmailSmtpSettingsHandler creates a
SmtpServerSettings object.

Or look at:
// ( above exert from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingnewsectionhandlers.asp )
// also see http://support.microsoft.com/default.aspx?scid=kb;en-us;309045
// Article ID : 309045


"ttrudeau" <ttrudeau@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8FCB62D2-4217-42BC-8E05-DCB5654BE0C6@xxxxxxxxxxxxxxxx
That's a very nice solution that they put together. The only problem is
that
it looks like it relies on the assembly being in a certain folder and
precludes it from being loaded in the GAC.

That restriction would certainly make things more clear-cut, but I'm not
sure if I want to add that restriction. Assuming, I cannot use
application
configuration files for the pluggable services, what do you think would be
a
good location?

"sloan" wrote:

http://www.eggheadcafe.com/articles/20041204.asp

Check out Peter's code for a windows service.

You're not as interested in.... the msmq or command pattern, but rather
how
he deploys different dll's with their OWN config files.

I added some functionality to one of his libraries as well, you'll have
to
search the forum for it.




"ttrudeau" <ttrudeau@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4FDF45D9-F242-4D55-AF27-B5B2E8630C35@xxxxxxxxxxxxxxxx
I'm creating a Windows Service that will manage pluggable objects that
perform certain work based on a set of interfaces. The configuration
data
for the hosting object in the service contains the information to
create
the
individual pluggable objects (primarly type information -- what and
where).
The configuration data for each pluggable object will contain data
related
to
what it does (i.e. more or less unique to the object). The service
will
run
under the NetworkService account. And there will be an MMC snap-in
designed
to modify the configuration for the hosting and pluggable objects.

I'm pretty sure I want to store this information in XML configuration
files
not the Registry or some database. Where would be the best place to
store
them? (I assume the NetworkService account doesn't get a user folder
under
Documents and Settings; otherwise, I'd probably store at least the
hosting
object data as user settings in the application configuration file.)






.



Relevant Pages

  • Re: [RFC] libcg: design and plans
    ... In general - cgroup is a very flexible subsystem that can be used in a wide variety of ways and modes and trying to create a universal simple API would more likely result in something hard to manage and work with. ... We have been working on a library for control groups which would provide ... Provide persistent configuration across reboots ... Similarly a configuration file will be ...
    (Linux-Kernel)
  • Re: An ssh Question
    ... Connecting to xxxxxxxxxxxxxx.com port 22. ... an ssh configuration problem - that is, the FreeBSD ssh client can't do ... # This is the ssh client system-wide configuration file. ...
    (freebsd-questions)
  • Re: Going nuts - Configuration Error
    ... I've turnded off indexing in the IIS. ... An error occurred during the processing of a configuration file ... partial, or location-based assembly bind). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Remote Web Workplace SBS 2003 Can No Longer Be Accessed: Server Error in /Remote Application
    ... Server Error in '/Remote' Application. ... configuration file required to service this request. ... Attempting download of new URL ...
    (microsoft.public.windows.server.sbs)
  • Re: Configuration data for a Windows Service
    ... in the same directory as the hosting application ... configuration files for the pluggable services, what do you think would be ... to modify the configuration for the hosting and pluggable objects. ... I'm pretty sure I want to store this information in XML configuration ...
    (microsoft.public.dotnet.framework)