473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.Reflection.Assembly.GetExecutingAssembly(). 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 1771
On Jan 10, 7:04 am, "Anil Gupte" <anil-l...@icinema.comwrote:
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.Reflection.Assembly.GetExecutingAssembly(). Location()
End If

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

TIA,
--
Anil Guptewww.keeninc.netwww.icinema.com
You can use the System.Diagnostics.Debugger.IsAttached 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*******@icinema.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.Reflection.Assembly.GetExecutingAssembly(). 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.Reflection.Assembly.GetExecutingAssembly(). 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.comwrote:
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.Reflection.Assembly.GetExecutingAssembly(). Location()
End If

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

TIA,
--
Anil Guptewww.keeninc.netwww.icinema.com
I assign a value of "Debug" or "Release" to the AssemblyConfiguration
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.Diagnostics.Debugger.IsAttached 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*******@icinema.comwrote in message
news:On*************@TK2MSFTNGP04.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.Reflection.Assembly.GetExecutingAssembly(). 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
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...
7
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...
9
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...
3
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...
3
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...
3
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:...
6
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++...
7
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...

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.