By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

FileVersionInfo.IsDebug

P: n/a
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?
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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 Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 21 '05 #2

P: n/a
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).
-----Original Message-----
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 versionresource, 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 waywould be to use the DEBUG symbol that's usually defined in Debugbuilds. So you can do

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

Another way is to use Reflection to look for the DebuggableAttributeon the assembly.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
.

Jul 21 '05 #3

P: n/a
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...o_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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.