Get build configuration string (Debug or Release) at run time

J

John Williams

How can I get the build configuration string (Debug or Release) at run
time?

I currently use the following code to get the version number from the
AssemblyInfo.vb AssemblyVersion attribute, and wonder if there is
something similar for getting the build configuration.

Private Function getAppVersion() As String

Dim aName As System.Reflection.AssemblyName

aName = Reflection.Assembly.GetExecutingAssembly().GetName()
getAppVersion = " - Version " + aName.Version.Major.ToString + "." +
aName.Version.Minor.ToString

End Function
 
M

Mattias Sjögren

John,
How can I get the build configuration string (Debug or Release) at run
time?

How about:

Dim config As String = "Release"
#If DEBUG Then
config = "Debug"
#EndIf



Mattias
 
H

Herfried K. Wagner [MVP]

* Mattias Sjögren said:
How about:

Dim config As String = "Release"
#If DEBUG Then
config = "Debug"
#EndIf

.... in the prioject properties, "Configuration settings" -> "Build" the
checkbox "Define DEBUG constant" must be checked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top