'Error: You are debugging a Release build of X.dll

Background

I have an ASP.NET MVC application project, along with various other projects within a Visual Studio solution. The different projects use various versions of the NPoco library as follows:

  • The MVC project includes a version of NPoco through NuGet.
  • Some other projects include a (probably different) version of NPoco through a reference to a DLL (not the DLL provided through NuGet).
  • One of the projects is the source code of a version of NPoco with some alterations made.

I'm using Visual Studio 2015 Update 3 14.0.25422.01.

Error

For some reason, when I launch this application in the debugger using the normal Start Debugging command in Visual Studio, it launches, but it also produces the following warning:

You are debugging a Release build of NPoco.dll. Using Just My Code with Release builds using compiler optimizations results in a degraded debugging experience (e.g. breakpoints will not be hit).

If I press Continue Debugging, everything seems to still work as usual, including breakpoints.

This problem only started happening recently.

Question

  1. Anyone know what caused the above error?
  2. Do I have something misconfigured?


Solution 1:[1]

Disable this option under Debug->Options->Suppress JIT optimization on module load (Managed only).

A connect report submitted before:

https://connect.microsoft.com/VisualStudio/feedback/details/2116788/flag-optimize-is-passed-to-the-debugger-even-while-the-build-settings-optimize-code-is-not-enabled-on-mvc-c-web-projects-when-using-just-my-code.

Please also make sure that all projects are in debug mode, Optimize code was unchecked like this case:

VS2015 Project no longer runs in debug mode

Solution 2:[2]

"Optimize code" option is there on visual studio project level. Remove that for debug mode.

Solution 3:[3]

Just had a similar issue that I was able to fix by Cleaning my solution 3 times and rebuilding. Hope this helps other people too.

Solution 4:[4]

I also encountered the similar problem in Visual Studio 2019 Following Steps solved my issue Debug-> Options->Uncheck Enable Just my code option

Solution 5:[5]

This happened to me while using NuGet packages.

Let's say you want to debug code from Project1...

If you have a Project1 NuGet package referenced in any of the projects in the solution (.sln), make sure you remove it. Instead of adding Project1's NuGet package, add Project1 (.csproj) directly as a reference to any given project that needs Project1 in the solution. This way you'll be able to step through code while debugging and Visual Studio won't bark about "Release" version anymore.

If Project1 is from a different solution (.sln), you can right click your current solution and select Add existing item... pick Project1.csproj for example. Then go to any project that needs Project1 => right click => Add => Reference and pick Project1.

Solution 6:[6]

Right click on your solution and select Properties.

Then, go to Configuration Properties on the left and select Configuration under it. Make sure that the Configuration of the project you are running is in 'Debug' and not in 'Release'.

If the Configuration is in 'Release' you would get this error.

Solution 7:[7]

I have found that when you update a Nuget package that has a dependency on a referenced project (that you may have modified version) it replaces this with the Nuget version of the dll.

To fix this after updating (or adding) you nuget package you need to remove the reference to the dll (e.g. NPoco) and the add a project reference to the project with your modified version.

Solution 8:[8]

In my case some tricky trickster put this into the AssemblyInfo.cs file:

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]

Commented it out and it started working

Solution 9:[9]

Right click solution > Properties > Configuration Manager > Active solution configuration : New
Give a name to new solution configuration. Copy setting from "Debug".

I did everything for this error but just this solution worked.

Solution 10:[10]

In case someone is still having this issue, for me it was because I confused the GAC by installing the software I was trying to debug.

The fusion logger helped me figure this out ha.

Solution 11:[11]

In my case I removed Webapplication.dll for my project and removed contents in release folder. Rebuild project again and it works for me.

Solution 12:[12]

Another reason for this problem is the following "assembly-level" attribute:

[assembly: System.Diagnostics.Debuggable(true, false)]

(I found this out only by accident....who checks AssemblyInfo.cs when one experiences such problems....right - nobody)

Edit: just saw that someone else added this already..... (with other parameters though) - also - the reason for this attribute was also "decompile from exe" (we lost source-code for that particular project :-/ )

Solution 13:[13]

I had the same issue after moving my projects to a new machine.

Downloading the proper Target framework worked for me. My project uses .Net Framework 4.7.2 and the error went away after downloading .Net Framework 4.7.2.

Solution 14:[14]

This happened to me in VS2017, even after changing the configuration to Build. The issue was resolved when restarting VS2017

Solution 15:[15]

This is one of typical Microsoft errors that could have 20 solutions. For me, I rebooted my server that was running visual studio 2017 and it fixed the issue.

Solution 16:[16]

I encountered this problem (in Visual Studio 2017) for the first time today. For me, it turned out to be caused by a different version of my application, built in Release mode, running under the same application pool in IIS that I was debugging with. I gave the different version of the application its own application pool and the problem disappeared.

Solution 17:[17]

I tried.. Cleanup entire solution, Rebuild entire solution, Restart Visual Studio... But no help.

Finally,

I restarted my PC

and then started Visual studio, Cleaned and Rebuilt, then Debugging works flawlessly :)

Solution 18:[18]

This started happening randomly in the middle of the day for me.

Tried Clean, deleted all BIN and OBJ folders... nothing worked.

I had to stop/start the IIS application pool for the ASP.NET solution to fix it.

Solution 19:[19]

Close and Restart visual studio worked for me

Solution 20:[20]

Had some advanced settings in ProjectName.csproj.user. After deleting, it worked

Solution 21:[21]