How to find out by a dll that it is using by a web application or window application

  • Thread starter Thread starter anilkumarup
  • Start date Start date
A

anilkumarup

Problem: I have to develop a component(dll) in C# for user management
section. the component will serve to any type of apllication like web
or window. Now the problem is in defining connection string (sql
server). If dll will be able to find out that it is calling by a web
application then the connection string can be picked from WEB.CONFIG
and in case of window application from somewhere else. Can any one
please help me for this
 
If dll will be able to find out that it is calling by a web
application then the connection string can be picked from WEB.CONFIG
and in case of window application from somewhere else. Can any one
please help me for this

There are probably lots of ways to do this; here's one that I think should
work (this is VB code, you'll have to C#-ify it)

\\\
'Do we have an HttpContext?
If System.Web.HttpContext.Current Is Nothing Then
'We are running in a WinForms application
Else
'We are running in a web application
End If
///

HTH,
 
Back
Top