Windows Vista Forums

How do I check if class library is being used by web or windows ap
  1. #1


    rgliane Guest

    How do I check if class library is being used by web or windows ap

    I have a method in a common class library that reads the application config
    file. If the library is used by a Windows app, it should use
    ConfigurationManager to read the app.config file. If the library is used by
    a Web app, it should use WebConfigurationManager to read the web.config file.




    Is there a programmatic way to determine what kind of app is running? Or is
    there another approach to handle this kind of thing?


      My System SpecsSystem Spec

  2. #2


    dotNetDave Guest

    RE: How do I check if class library is being used by web or windows ap

    Common class libraries should not read configuration files.... this makes
    them too dependant on the outside world. If the class needs something like a
    database connection string it should always be sent into it via a property or
    better yet the constructor.

    David

    ======================================
    David McCarter [Microsoft MVP]
    www.dotNetTips.com
    David McCarter''''s .NET Coding Standards available at:
    http://www.cafepress.com/geekmusicart.1654787045


    "rgliane" wrote:

    > I have a method in a common class library that reads the application config
    > file. If the library is used by a Windows app, it should use
    > ConfigurationManager to read the app.config file. If the library is used by
    > a Web app, it should use WebConfigurationManager to read the web.config file.
    >
    >
    > Is there a programmatic way to determine what kind of app is running? Or is
    > there another approach to handle this kind of thing?
    >

      My System SpecsSystem Spec

How do I check if class library is being used by web or windows ap problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Constants Class Library Alan Sloan .NET General 4 19 Feb 2010
How do I install a class library using a Windows MSI file? Rico .NET General 3 09 Sep 2009
Adding class library to website Fresno Bob .NET General 1 21 Jul 2008
Using a C# Class Library with VB6 lord.torall .NET General 2 26 Apr 2008
Summary comments in Class Library Brian .NET General 3 12 Apr 2008