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

Strange problem with DEBUG directive

P: n/a
Hello!

Recently I had a strange problem with Visual C# 2005 beta 1.
When I ran(F5 key) a program, <#if DEBUG> statement was not working.
It ran as RELEASE mode.
So I had to manually define DEBUG to make #if DEBUG work.
When I first started the project, this problem didn't exist.
The problem started to exist in the middle of doing the project.

Today, I decided to figure out what went wrong.
Finally I pinpointed the cause of the problem.
In the *.csproj file, I had the following lines.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>
</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
</PropertyGroup>

I compared them with normal ones and found out that they should be like the
following.
(See <DefineConstants> lines)

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>//***DIFFERENT
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>//***DIFFERENT
</PropertyGroup>

I've never edited the file (Actually I haven't opened it.)
I don't think there's a interface to modify it from VC#.
I think something affected it.
Has anyone experienced same thing?

TIA.
Sam
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I tested it a little bit more and found something strange.

With a fresh project, <#if DEBUG> works fine.
Now I go to the project property and select Build page and set a conditional
compilation symbol.
Save the change.
Now remove the conditional compilation symbol and save.
<#if DEBUG> doesn't work by now.
I checked the *.cproj file and the problem is same as I described below.
Is it a feature or bug?

Sam

"Sam Kong" <su***********@hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
Hello!

Recently I had a strange problem with Visual C# 2005 beta 1.
When I ran(F5 key) a program, <#if DEBUG> statement was not working.
It ran as RELEASE mode.
So I had to manually define DEBUG to make #if DEBUG work.
When I first started the project, this problem didn't exist.
The problem started to exist in the middle of doing the project.

Today, I decided to figure out what went wrong.
Finally I pinpointed the cause of the problem.
In the *.csproj file, I had the following lines.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>
</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
</PropertyGroup>

I compared them with normal ones and found out that they should be like
the following.
(See <DefineConstants> lines)

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>//***DIFFERENT
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>//***DIFFERENT
</PropertyGroup>

I've never edited the file (Actually I haven't opened it.)
I don't think there's a interface to modify it from VC#.
I think something affected it.
Has anyone experienced same thing?

TIA.
Sam

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.