Re: Class Library Configuration Files

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Mar 28, 3:03 am, "Peter Bradley" <pbrad...@xxxxxxxxxx> wrote:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0.
How on earth do you manage configuration settings in a class library in .NET
2.0? In version 1.1, we used a handy class called AssemblySettings that
someone (I forget his name) had written. When the class library was
finished, you deployed it to the GAC and put the configuration files in the
GAC with the class library assembly. This no longer works. In fact trying
to get configuration data from anywhere but the calling executable falls
over.

This can't be correct. Our n-Tier architecture uses class libraries to
access data from the database and needs to obtain a connection string from a
configuration file. It's no good putting the configuration in the calling
executable because the calling executable does not know anything about the
database, and anyway the whole point of a class library is that it can be
called by many other objects. We don't want the same configuration data
spread all over the place.

Surely there's a way to fix this. Does anyone know how?

Peter (spitting blood and calling Microsoft all sorts of things you don't
want to hear)

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
question.

Brian

.



Relevant Pages

  • Re: Configuration files for Services and Class Libraries
    ... if your class libraries have configuration options that need ... "Florida Coder" wrote in message ... > public class AssemblySettings ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Configuration files for Services and Class Libraries
    ... if your class libraries have configuration options that need ... "Florida Coder" wrote in message ... > public class AssemblySettings ...
    (microsoft.public.dotnet.framework)
  • Re: Erroneous Compile Errors
    ... winforms custom controls, some class libraries and 1 ATL3 COM DLL. ... > If I then switch back to the original solution configuration then it also builds with no errors. ...
    (microsoft.public.vsnet.general)
  • Class Library Configuration Files
    ... How on earth do you manage configuration settings in a class library in .NET ... to get configuration data from anywhere but the calling executable falls ... Our n-Tier architecture uses class libraries to ... database, and anyway the whole point of a class library is that it can be ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: app.config in Class Libraries
    ... class libraries do not work with app.config files for ... they should read the settings that are in the app.config file ... You should only have one configuration file for your app. ... add a connection string to the project settings, ...
    (microsoft.public.dotnet.languages.csharp)