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.   


  3. #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
Similar Threads
Thread Forum
.NET Constants Class Library .NET General
How do I install a class library using a Windows MSI file? .NET General
Adding class library to website .NET General
Using a C# Class Library with VB6 .NET General
Summary comments in Class Library .NET General