简体   繁体   中英

Visual Studio C# app won't build with debugging info

My C# WPF App won't load the symbols file using Visual Studio 2017. I've looked online and checked for the common issues, but can't debug my app. This is new behavior. It had been working (at least a few months ago) as part of a multi-project solution. I have no idea what has changed.

I have a breakpoint set after Main() and it shows solid red until I attempt to run in Debug configuration. As a breakpoint didn't stop the execution, I explicitly break.

[STAThread]
static int Main(string[] args)
{
    Application.EnableVisualStyles();   // breakpoint on this line
    Application.SetCompatibleTextRenderingDefault(false);

    Debugger.Break();

Now when running, it pops up with "Symbol file not loaded" and it says "Binary was not built with debug information".

Checking the "Active (Debug)" configuration project properties, in the Build pane, I see

[x] Define DEBUG constant
[x] Define TRACE constant
[ ] Optimize code

and in the Advanced Build Settings dialog

Debugging Information: Full

Running Build->Clean and then Build->Rebuild and I see both the app.exe and app.pdb files newly created in bin/Debug/ directory. When deleting the bin/ and obj/ directories and rebuilding, I still get the same error when attempting to debug the app.

When I look at the Debug output, along with various loaded Windows DLLs, symbols loaded, I see my application with "Modules was built without symbols."

From the Debug->Windows->Modules window I see my app with "Optimized: No" and "Symbol Status: Binary was not built with debug information." In this same window, I right-clicked my application, selected "Load Symbols" and selected the bin/Debug/app.pdb file. It said, "A matching symbol file was not found in this folder".

I'm going mad trying to figure this one out. It seems it should be built with debug information, but it isn't. Can anyone point me in the right direction?

I'm going mad trying to figure this one out. It seems it should be built with debug information, but it isn't. Can anyone point me in the right direction?

It is quite strange issue. I think you could try these suggestions

Suggestion

1) please check whether Assembly Name(Right-click on project--> Application ) has whitespace, if so, you should delete the whitespace and rebuild again to test it.

2) enable Define DEBUG constant and Define TRACE constant by right-click on project--> Build .

3) enable option Enable Just My Code and Use Managed Compatibility Mode under Tools --> Options --> Debugging --> General

4) check whether your xxx.csproj file has <DebugType>full</DebugType> node. If not,you could add it in xxx.csproj :

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
  <DebugType>Full</DebugType>
</PropertyGroup>

5) Close VS Instance, delete .vs hidden folder under the solution folder, bin and obj folder. Then restart your project to test again.

6) If you install several nuget packages, you could run this command under Tools-->Nuget Package Manager-->Nuget Package Console:

update-package -reinstall

7) disable any third party extensions under Tools-->Extensions and Updates in case some extensions cause this behavior. And do not forget to restart VS.

8) if your VS has any latest update, please update it.

In addition ,

If the new created wpf VS2017 project can be debugged successfully and your wpf project is an old project from the old VS version, I suggest you could create a new wpf project in VS2017 and then migrate the old into the new one to test whet.

You can copy the packages.config file from the old project into the new project's root directory and then run update-package -reinstall to reference these packages to your project automatically.

Any feedback will be expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM