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

R

rgliane

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?
 
D

dotNetDave

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top