473,606 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recognizing Release vs. Debug

Is there any way to define a variable that recognizes Debug versus Release
versions? Basically, in the two versions, I want to use different
directiories for certain tasks. For example

If (Version is Release)
ContentFilesDir = "C:\Content "
Else
ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
End If

I know C++ has something like this (IFDEF?), but how do I do it in VB.Net
2003?

TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com
Jan 10 '08 #1
5 1781
On Jan 10, 7:04 am, "Anil Gupte" <anil-l...@icinema.co mwrote:
Is there any way to define a variable that recognizes Debug versus Release
versions? Basically, in the two versions, I want to use different
directiories for certain tasks. For example

If (Version is Release)
ContentFilesDir = "C:\Content "
Else
ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
End If

I know C++ has something like this (IFDEF?), but how do I do it in VB.Net
2003?

TIA,
--
Anil Guptewww.keenin c.netwww.icinem a.com
You can use the System.Diagnost ics.Debugger.Is Attached to see if a
debugger is running, or you can use the #If Debug precompiler
statement for if...then blocks as well.

Thanks,

Seth Rowe [MVP]
Jan 10 '08 #2
"Anil Gupte" <an*******@icin ema.comschrieb
Is there any way to define a variable that recognizes Debug versus
Release versions? Basically, in the two versions, I want to use
different directiories for certain tasks. For example

If (Version is Release)
ContentFilesDir = "C:\Content "
Else
ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
End If

I know C++ has something like this (IFDEF?), but how do I do it in
VB.Net 2003?

#if DEBUG then
ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
#Else
ContentFilesDir = "C:\Content "
#End If

The DEBUG constant is defined in the project properties for the Debug
configuration only. (In VB 2008 Express @ folder Compile -Advanced
Compile Options...
Armin

Jan 10 '08 #3
On Jan 10, 6:04*am, "Anil Gupte" <anil-l...@icinema.co mwrote:
Is there any way to define a variable that recognizes Debug versus Release
versions? *Basically, in the two versions, I want to use different
directiories for certain tasks. *For example

If (Version is Release)
* * ContentFilesDir = "C:\Content "
Else
* * ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
End If

I know C++ has something like this (IFDEF?), but how do I do it in VB.Net
2003?

TIA,
--
Anil Guptewww.keenin c.netwww.icinem a.com
I assign a value of "Debug" or "Release" to the AssemblyConfigu ration
attribute depending on the value of the #DEBUG precompiler variable.
That way the assembly is stamped with the information needed to
determine whether what build configuration was active. You could then
pull the value of that attribute at runtime to do what you are wanting
to do.
Jan 10 '08 #4
Anil Gupte wrote:
Is there any way to define a variable that recognizes Debug versus Release
versions?
Depends what you mean by "Debug".
No, I'm not kidding.

If you mean ...

"was this executable was /compiled/ in Debug /Mode/?"

.... then use:

#If DEBUG Then
#Else
#End If

On the other hand if you mean ...

"is this executable currently /being/ debugged?"

.... then you need:

If System.Diagnost ics.Debugger.Is Attached Then
Else
End If

HTH,
Phill W.
Jan 10 '08 #5
Thanx All - you made it very clear.

--
Anil Gupte
www.keeninc.net
www.icinema.com

"Anil Gupte" <an*******@icin ema.comwrote in message
news:On******** *****@TK2MSFTNG P04.phx.gbl...
Is there any way to define a variable that recognizes Debug versus Release
versions? Basically, in the two versions, I want to use different
directiories for certain tasks. For example

If (Version is Release)
ContentFilesDir = "C:\Content "
Else
ContentFilesDir =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location()
End If

I know C++ has something like this (IFDEF?), but how do I do it in VB.Net
2003?

TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com


Jan 11 '08 #6

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

Similar topics

1
1892
by: Stanley | last post by:
I am working with Exceptions and have found a bit of a problem for me. Using the code below in Debug I get the info I want which is basically: -Line of error -Column of error -Method where error happened However, when you compile to Release version you get no line or column numbers. So I assume this is because the .pdb file holds all of the info regarding the lines and columns or something to that order. I am not really to sure what...
7
2896
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by using the following code in Page_Load event handler. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim intcount As Integer intcount = 0 For intcount = 0 To 4
9
1990
by: dee | last post by:
Hi I'm about to upload my site and I have switched to release version. Is that enough or do I still need to disable <compilation defaultLanguage="vb" debug="true" /> the debug="true" in the .pdb file? Is the .pdb necessary for the release version? Thanks a bunch. Dara
3
2882
by: Steve Franks | last post by:
I'm using Visual Studio 2005 RC and cannot figure out how to produce a "release" build. Am I doing something wrong? I'm wondering if perhaps MS locked out the ability to produce a release build when using the RC since it does not have a go-live license? Or maybe I'm just doing something wrong. I do not want to go live with a release build. Rather I just want to test locally to see if there is a performance difference and also to...
3
2188
by: | last post by:
Since I need to dotfuscate my exe file anyway, does it make any difference if I use Debug or Release versions. Would a Debug version be easier to decompile/study/reverse engineer than a Release version, both having been dotfuscated by the standard dotfuscator of visual studio 2003 ? Tia
3
4024
by: Haldun ALIML | last post by:
Suppose that you have below property in some class, #if DEBUG public string DebugInfo { get { return "INDEX : " + _name + "\n" + "Index Owner : " + _owner.Name + "\n" + "Index Column Count: " + _columns.Count + "\n"; }
6
9131
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++ project. I then add a class library, and add a reference to this project in the first project. When I do a release build, I see the following in the output from the DLL compile: /OUT:"C:\Documents and Settings\Andrew\My Documents\Visual Studio
7
3647
by: news.microsoft.com | last post by:
I have an asp.net 2.0 project that when I change the build configuration to release I get the following error: Command line error BC2014: the value 'None' is invalid for option 'debug'. If I go into the projects Advanced Compile Options and change the Generate Debug Info dropdown from None to PDB-Only the error goes away. Can anyone explain why I have to do this and what can I do to get the one option to work on a asp.net project? ...
3
1974
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set to RELEASE? My current project uses about 8 dlls I've written in the past, but I don't want to keep re-compiling them for debug/release depending on whether I'm compiling the current project for debug/release.
0
8015
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
7951
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
8439
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...
0
8430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8094
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,...
1
5966
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
5465
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3930
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1296
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.