Unable to debug C# solutions
-
Wednesday, December 27, 2006 5:18 AMI'm using Visual Studio 2005 Pro.
This problem is repeatable with archived code on backup discs as well as new solutions.
When I attempt to run my apps in Debug Configuration with breakpoints, I get the message:
the following module was built either with optimizations enabled or without debug information.
D:\Programming\Solutions\******...
To debug this module, change its project build configuration to Debug Mode. To suppress this message, disable the 'Warn if no user code on launch' debugger option.
Here's a screenshot.
This is done with a brand new solution. File > New > Project > C# > Windows/Windows Application > Ok > Build > Run.
[update]
as par this thread, I've tried restoring factor default settings. No dice.
[update2]
If I RClick on the project in the solution explorer, and hit 'clean' or 'rebuild', then F5, I'm good and my breakpoints work.
However, as soon as I make a code change and hit F5 next, I'm back to the same behavior as before.
All Replies
-
Wednesday, December 27, 2006 10:48 AM
I actually know what is causing this behaviour but out of the box it shouldn't be set like this, strange. Anyway here is how to solve this one:
- Right-mouse click the project and select "Properties"
- Click on the "Build" tab
- At the bottom in the "Output" section there is a button "Advanced", click on it (this will open the Advanced Build Settings dialog)
- In that dialog there is again a "Build" section. Set the "Debug Info" to either "Full" or "PDB-only".
- Proposed As Answer by dotmeatpack Thursday, July 22, 2010 1:57 AM
-
Wednesday, December 27, 2006 4:48 PMI guess I should have been more specific.
The said combo box is already set to "Full." "PDB-Only" doesn't change the behavior.
For the sake of credability, here's another screenshot. -
Wednesday, December 27, 2006 5:23 PM
You also have this for new projects you say, right? Can you create a new dummy console application and post the contents of the .csproj file?
-
Wednesday, December 27, 2006 6:41 PMThanks for your continued help, Gabriel.
Okay, I just created a brand new C# Project. To validate the continued behavior of my IDE, I tossed some sample code in:
-------
int i;
i = 33;
-------
I placed a breakpoint on the second statement.
Ran it. It broke at the said statement. Cool.
I stopped debugging, then ran it again. This time, the breakpoint bullet became a hollow red dot, and it did't stop like it should have.
I added a third line
-------
int y = i;
-------
Ran it, it debugged correctly. Ran it again, didn't debug at all.
So yes, this happens with "blank" projects.
Here's the csproj for the solution I just created.
LINK -
Wednesday, December 27, 2006 6:49 PMSorry Gabriel, it never occured to me to try a console app... I've never written one in C#.
I just tried one, and with the same code snippits as above, the behavior is still incorrect.
Here's my console app csproj:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1BB3B4F4-9B96-40D8-A6B2-74BEB402C6E1}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleApplication1</RootNamespace>
<AssemblyName>ConsoleApplication1</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project> -
Wednesday, December 27, 2006 7:00 PM
I don't see anything special in the .csproj file. What you can do is try each of the following:
- Start the project then in Devenv.exe menu Debug => Windows => Modules. Right-click the ConsoleApplication.exe and choose "Load Symbols" from the list. Then specify the .pdb file in the \bin\debug\ folder assuming that it exists.
- Perform a Rebuild between code changes, this will clean the solution first and perform a build
- Delete the .suo file between code changes, the .suo file contains the location of the breakpoints
-
Wednesday, December 27, 2006 7:28 PM1. I don't have "Modules" in the Debug::windows menu.
2. `Rebuild` resolves the issue for the next subsequent build. But I've never had to do this before until yesterdays reformat of my hard drive, and it feels clumsy and out of the way, and quickly becomes irksome and feels like it's impacting my productivity and my sanity.
3. I'll try. -
Thursday, December 28, 2006 12:29 PM
J Hallam wrote: 1. I don't have "Modules" in the Debug::windows menu.
2. `Rebuild` resolves the issue for the next subsequent build. But I've never had to do this before until yesterdays reformat of my hard drive, and it feels clumsy and out of the way, and quickly becomes irksome and feels like it's impacting my productivity and my sanity.
3. I'll try.Any news?
-
Thursday, December 28, 2006 1:12 PMStill the same situation.
I'm aggravated to the point that I'm going to have to reformat my hard drive again tonight if I can't get this solved... -
Thursday, December 28, 2006 1:30 PM
Download and run Process Explorer and try to find out which process has the .PDB file locked after the first run:
http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx
-
Thursday, December 28, 2006 2:27 PMI downloaded process explorer and can't get anything intelligible from it...
-
Thursday, December 28, 2006 4:00 PM
J Hallam wrote: I downloaded process explorer and can't get anything intelligible from it... So when you do a find on for example ConsoleApplication1.pdb there are no process that have a handle to that file?
-
Thursday, December 28, 2006 4:16 PMGabriel, I think I'm getting a tad warmer here.
This is a real hack, but it seems to work. The inherent disadvantage is that the build is a bit slow due to the extra step.
I went into properties > build events > pre build >
and added this line:
C:\PROGRA~1\MICROS~2\Common7\IDE\devenv.exe /clean Debug $(SolutionPath) -
Thursday, December 28, 2006 4:16 PM>>So when you do a find on for example ConsoleApplication1.pdb there are no process that have a handle to that file?
Correct -
Thursday, December 28, 2006 6:45 PM
Well it's a long shot but here are more things you can try.
- Run the following:
- regsvr32 %windir%\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll
- regsvr32 %windir%\Microsoft.NET\Framework\v2.0.50727\mscordbi.dll
- Repair or reinstall the .NET Framework 2.0
I also never asked whether or not you have installed Service Pack 1 for Visual Studio 2005?
-
Thursday, December 28, 2006 8:06 PM
- Run the following:
- regsvr32 %windir%\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll
- regsvr32 %windir%\Microsoft.NET\Framework\v2.0.50727\mscordbi.dll
- Repair or reinstall the .NET Framework 2.0
done so already
I also never asked whether or not you have installed Service Pack 1 for Visual Studio 2005?
installed it, same behavior. -
Friday, December 29, 2006 4:11 AM
Well I figured that since the .pdb does not get updated the second time that maybe there are some issues with the library that contains the API's for emitting the symbols in the .pdb file. But I am out of options. Are you running maybe exotic Add-ins or anything else that doesn't come with Visual Studio out of the box? Also have you tried disabling the Anti-Virus?
-
Friday, December 29, 2006 6:24 PMOnly antivirus is zone alarm, and it's shut off most of the time.
No addins what so ever.
I think I'm going to write this off as unsolvable and use my pre-build command line as a hack/work around for the time being.
Thanks for your continued support. -
Friday, December 29, 2006 6:35 PMToo bad we couldn't not solve this.
-
Tuesday, August 25, 2009 7:20 PMWow, this really is an old issue! Unfortunately I even meet it in VS 2008! Unable to debug c# 2008!
the following module was built either with optimizations enabled or without debug information.
C:\Program Files\******...
To debug this module, change its project build configuration to Debug Mode. To suppress this message, disable the 'Warn if no user code on launch' debugger option.
Any better suggestion now?
-
Wednesday, August 26, 2009 1:54 PMModerator
The path you gave is C:\Program Files. Unless you've changed your defaults then projects don't run from that directory. The directory should be whereever your project is \bin\debug. The important points are to confirm that you are using F5 to start debugging, that the configuration that you are building and debugging is set to Debug, that optimizations are disabled in the Project\Build settings and that the program you are actually debugging is the application you are building. Given the fact that your project path doesn't appear right I'd say you are not running the code you're building.
Michael Taylor - 8/26/09
http://p3net.mvps.org -
Thursday, July 22, 2010 1:57 AM
Thanks Gabriel for that tip, it actually helped me. It's just that in Visual Studio 2010, doing that process is a bit different, take a look at this:
1. On the Solution Explorer , right click on your solution, and go to "Properties"
2. Click "Configuration Properties" and then click on "Configuration"
3. A table appears, select "Debug" on the dropdownmenu of the "Configuration" column and put a check on the checkbox of the "Build" column of the project you are working on
4. Click OK
For some tips and tricks in ASP.NET, you may check out this site:
- Edited by dotmeatpack Thursday, July 22, 2010 2:00 AM removed code block
- Proposed As Answer by dotmeatpack Thursday, July 22, 2010 2:01 AM

