FileVersionInfo.IsDebug

  • Thread starter Thread starter Loyd Nelson
  • Start date Start date
L

Loyd Nelson

I am trying to use the IsDebug property of the
FileVersionInfo class at runtime to determine if the
current application is a debug version. I know the
current configuration that is being compiled is the Debug
configuration yet the value of the property is false. I
can find no documentation that indicates what sets the
property and how the property is related to the compile
time configuration. More documentation in this area
would be appreciated. I also found that there is an
AssemblyConfigurationAttribute but this appears to be a
programmer-defined string that is not related to what the
compiler is doing. Similarly, there is a IsPreRelease
property for FileVersionInfo. How does that value get
set? The documentation in this area is pretty poor.
What really controls these properties?
 
Loyd,
I am trying to use the IsDebug property of the
FileVersionInfo class at runtime to determine if the
current application is a debug version. I know the
current configuration that is being compiled is the Debug
configuration yet the value of the property is false. I
can find no documentation that indicates what sets the
property and how the property is related to the compile
time configuration.

It's up to the compiler to set these flags in the executable's version
resource, but IIRC the C# and VB.NET compilers don't do so as expected
(i.e. IsDebug always returns false).

There are other ways you can do what you want though. The easiest way
would be to use the DEBUG symbol that's usually defined in Debug
builds. So you can do

bool isDebug = false;
#if DEBUG
isDebug = true;
#endif

Another way is to use Reflection to look for the DebuggableAttribute
on the assembly.



Mattias
 
Mattias,

I saw your response to a similar question you answered on
Google. Thanks for responding. However, I am looking
for a more general answer. The FileVersionInfo class
contains a number of properties: IsPatched, IsPreRelease,
IsPrivateBuild, IsSpecialBuild..., that contain no
information about how they get defined. However, after
much searching (and luck), I did find at MSDN

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/wceui40/html/cerefversionstatement.asp

documentation that defines the VERSIONINFO resource-
definition statement, which curiously, contains a
fileflags value that defines a set of bits with names
corresponding to the properties mentioned above. (The
documentation happens to be under Windows CE -
interesting.) My bet is that is where the
FileVersionInfo properties get defined from. I haven't
had a chance to verify that yet. First, I need to figure
out how to define resource-definition statements in
the .NET development environment (I think the good
old .rc file is no longer used).
 
Loyd,
(The
documentation happens to be under Windows CE -
interesting.)

The desktop OS version of the docs are at

http://msdn.microsoft.com/library/en-us/tools/tools/versioninfo_resource.asp

My bet is that is where the
FileVersionInfo properties get defined from.

That's right.

First, I need to figure
out how to define resource-definition statements in
the .NET development environment (I think the good
old .rc file is no longer used).

The compiler will usually generate it for you. It will pull some of
the information (version, copyright etc.) from your assembly
attributes, but other options are just left in their default state.

But the command line compilers let you embed a custom resource file,
and in it you can put a VERSIONINFO resource if you want to provide
your own. See the CSC /win32res option (or VBC's /win32resource) for
details.



Mattias
 
Back
Top