We are developing several applications in Visual Studio 2010 using C # and .NET 4.0 on Windows. Two SilverLight applications using services from several WCF projects. Another is a console application.
We want to put some "common" functions in a separate library project in order to decompose and reuse the code. This library should know if the application is hosted (IIS, ASP.NET ...) as WCF services, or it works as a console application due to different file path processing.
In this regard, people point to the use of System.Web.dll to find out if the code is hosted using HttpContext, HostingEnvironment.IsHosted ... The problem is that this approach requires the inclusion of a link to the System. Web int he Library, which is unacceptable if this library refers to a console project with a client profile.
The idea is to use another method that does not require the use of the System.Web assembly.
David OlivΓ‘n Ubieto
source share