473,774 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I change my code depending on the build type?

I've got a function that needs to work slightly differently on the
development server from the production server, but of course I don't want to
be changing code just before compiling a release version!?

I'm thinking I could use some #if #else #endif type statements to change
certain things, depending on the build type. I'm thinking of something like
this in my .cs file...

#if DEBUG
private string MyFunc()
{
// debug version
}
#else
private string MyFunc()
{
// release version
}
#end if

Would this work!? If not, how could I achieve a similar effect? (.net 2)

Cheers
Dan
May 8 '06
10 1520
Thanks for your response Dan,

What's the actual behavior do you mean?

=============== ========
What's more worrying though, is that whether I compilation debug= to true
OR
false in my web.config, I always get the debug version, which would
indicate
that it doesn't seem to be making any difference?
=============== ========

Based on my local test, (in vs 2005 through file test server), the
conditional compiled block will just match the setting in the web.config's
<compilation debug=xxx> attribute. Also, I've tried set this attribute for
a particular sbu directory in the application directory and that worked(
the pages under that directory conforms to the sub web.config's compilation
setting).

Is there any particular setting or scenario in your application that could
cause the difference?

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


May 12 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1515
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each row. So some rows will have an EditCommandColumn, others just a text message in the last column. Is this possible? I am already using the ItemDataBound method to perform some function on each row, but I can't seem to change the datagrid's column...
7
1591
by: Tom | last post by:
How can I make code not execute for a debug build, but do execute for a production build? I have code which prompts for an account and password when the program starts up. It is a pain to have to answer that when I repeatly run the program during debugging, but it is desired by my client. Presently I just comment it out when I am debugging, but I was wondering if there was a more automatic way? Some type of conditional compilation...
0
1612
by: Jeff User | last post by:
I have my datagrid running pretty much with a EditCommandColumn and some TemplateColumn columns. There are two types of appearance changes I would like to make programatically from my C# code depending on various conditions. Column items are typical Labels in <ItemTemplate> and TextBoxes in <EditItemTemplate> forms. When the user clicks Edit, I would like to do the following:
11
4802
by: Wayne Cressman | last post by:
I'm writing a function to dynamically change a form validation script depending upon the user's choices. The form onsubmit is: onsubmit="writevalidate(this.select.value);return document.MM_returnValue" I then have the following function function writevalidate(selectvalue) { var1 = "\'form1\',\'type\',\'#q\',\'0\',\'Please enter your
45
18902
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
2
3261
by: pozitronic | last post by:
Hey all, I would like to do the following: I have 3 radio boxes. <input name="br" type="radio" value="first">Button1<br> <input name="br" type="radio" value="second">Button2<br> <input name="br" type="radio" value="third" />Button3<br>
2
1776
by: Gilbert Tordeur | last post by:
Hello, It is about a VB2008 intranet application. It uses a SQL Server database. The ConnectionString is defined in the connectionStrings section of the web.config file. This application uses ObjectDataSource objects, defined in design mode. I would like to use a different database depending on the execution environment (development or production).
4
3053
by: mistral | last post by:
Does it possible change favicon icon depending on browser type: display favicon.ico for Internet Explorer browsers, and favicon.gif for the rest browsers? Problem is that ugly MSIE can display only .ICO favicons, whereas other browsers support any favicon type - gif, png, jpg. Since gif favicons has much better quality than ico file, I'm wondering does it possible sort browsers with javascript and show appropriate favicon type for...
25
30991
by: Peng Yu | last post by:
Hi, It is possible to change the length of "\t" to a number other than 8. std::cout << "\t"; Thanks, Peng
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.