Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Conditional Compilation - Visual Studio

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

Overview

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.

Solution

(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 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.