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

Similar Threads
Thread Forum
.NET Constants Class Library
I need to create a .net class library (dll) that contains nothing but a bunch of constants. It doesn't matter if it's VB.NET or C#, but it must be...
.NET General
How do I install a class library using a Windows MSI file?
Hello, I'm new to VB.net and I have developed a COM visible class library / dll that I want to install on the target machine. I'm using an MSI...
.NET General
Icons in dll / assembly / class library
I want to change the default icon which shows in Windows Explorer for my dlls. By setting this key in the registry the first icon in the assembly...
.NET General
Adding class library to website
What is the default namespace of the class library? Try typing DAL. and see if stuff starts "appearing". Other way using DAL;
.NET General
RE: invisible classes outside the Class Library
Just change the access modifier on the classes you don't want exposed to internal instead of public. public class MyClass { } Would become: ...
.NET General
Using a C# Class Library with VB6
I hope I'm posting this in the right place.... I have a new C# class library written in Visual Studio 2008. I also have an existing VB6...
.NET General
Summary comments in Class Library
Hi, I am trying to format my comments for my class library. how do i insert new line feed so that all the text is not just jumbled in together...
.NET General