Jasinski Technical Wiki


Home Page
All Pages

Quick Search
Advanced Search »

Contributor Links

Create a new Page
File Management
Your Profile

Other Wiki Sections



Conditional Compilation - Visual Studio

Modified on Thu, Apr 26, 2012, 11:54 AM by Administrator Categorized as Visual Studio and Developer Tools


One project I worked one was code inherited from a client. The client had certain web services available within their internal network but which were not accessible from outside their network. This presented a problem when I worked on their code — specifically the sections that called these web services. This article explains a work-around involving conditional compilation in Visual Studio.


(1) Create a new Build Configuration via Build menu > Configuration Manager > Active Solution Configuration = {New...} > (call it the name of your company).

(2) In the code where the web service is called, conditionally "remove" the web service calls, like the following example.

#If CONFIG <> "AcmeCompany" Then

    result = webServiceClass.WebMethod();

#End If

(3) Make the new build configuration the active one. This can be done via the dropdown on the Standard toolbar, or via Build menu > Configuration Manager > Active Solution Configuration dropdown.

ScrewTurn Wiki version Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2022, Patrick Jasinski.