Re: Class Library Configuration Files


That's exactly what you have to do. A windows service is just an EXE.
If you create an EXE in .NET that is run as a windows service, then you can
create a config file where you place all of your configuration settings.

I am definitely of the same mind as what Brian described, that because
it is a class library, you should be specifying in the EXE that calls the
class library what the configuration is. It's just a matter of knowing
where your configuration file is going to be.

- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Peter Bradley" <pbradley@xxxxxxxxxx> wrote in message

"Brian Gideon" <briangideon@xxxxxxxxx> wrote in message
<snip />
There's another school of thought that says you should keep
configuration parameters out of the class library precisely because it
can be reused by multiple applications. Different applications might,
and often do, need to inject different parameters.

There are certainly cases where it makes sense to have a class libary
specific configuration file. I'm just not convinced this one of
them. And unfortunately I don't have an answer to your specific


Thanks for that Brian.

Perhaps I should expand a bit. The configuration file is for the data
access component of an n-Tier application. It is a class library that is
called by another class library (the business logic layer component). The
business logic layer component is a remote component hosted in a Windows
service. Therefore the nearest executable is the Windows service.

The real executable is the one on the client machine (or, more likely, Web
server). One of the main points about n-Tier development is that the
client is completely unaware of implementation details in respect of
things like data accesss. It just wants the data. We might, for example,
decide to move away from SqlServer to MySql. Such a move should leave the
client entirely untouched. The last thing we would want to do would be to
pass a connection string to the remote object: it's one of the things
we're trying to keep off the client - especially if the client is a Web

Whether or not configuration can be retrieved from the Windows service
AppConfig file, I don't know. I'll have to do some tests. It's not
great, though, doing it that way because it takes config away from the
thing you actually want to configure (the data access code).