"You are debugging a release build" when debug is selected - c#

I am attempting to debug my solution, which is set to start a few different projects. One of these projects is giving me an error when it is hit saying that it is running in release mode. This same solution has been running fine on Windows 7, but I just switched to a new machine running Windows 10 and am now getting this error message. I have attempted cleaning the solution and doing a rebuild with Debug and Any CPU selected to no avail. The code that is failing is within a class library that is referenced by a Web Api project. I am able to send a request to the Web Api that does not require the use of the class library and that works as intended.

Try opening configuration manager in visual studio and ensure that all of the projects are set to debug, I assume that some are release.

Go to
Project->Properties->Build
then Uncheck Optimize Code

As an alternative, after reading the docs here, I rebuilt once again and spotted a warning stating that some modules were optimized but that I had Enable Just My Code set. I then reverted Supress JIT Optimization on module load to its original value (selected) but de-selected Enable Just My Code. I am able to debug now

It happens to me another day that I had one solution with several projects.
Using "Add existing project" i had one library project - which is a Nuget. I wanted to debug this Nuget.
In the WebApi project that used the Nuget, I remove the reference to the Nuget and make a reference to the Class Library.
I was getting this message all the time. I did all the advices :
Mark "Define Debug Constant". Check Solution Configuration Props and check if projects are all in Debug etc...
It turns out that the Nuget was been referenced in all the other projects besides WebAPI. And I just remove it in one of my projects. This was the only and single problem :/

It happened to me as well. For me everything was in debug and still getting the error. I observed that it happened to me because, I had installed the executable on the same machine for which I was setting up the Dev environment. Uninstalling it solved the problem.

I have tried all solution above and didn't work. and I found this solution work :
Debug > Options > Debugging > General > (check) Surpress JIT optimization on module load (Managed only)

Related

Visual Studio 2019 Project Dependency with Yellow Icon

I have two brand new C# .NET Standard libraries. They each have a project reference to an older .NET 3.5 Framework library. Only one of the two have a yellow icon on the reference.
Everything builds and runs fine but the triangle still exists, why?
I would hope they have a better way to report reference issues
than an unlabeled yellow icon.
Not sure if it's your real question. But you can check the Error List window to get details about why yellow icon displays on the References.
Everything builds and runs fine.
For some scenario, the build in VS can succeed although some build warnings occurs. And it will only fail when some build errors exist.
I add reference to ForTest.dll in my project, this assembly is missing or not compatible with current project, then it displays yellow icon in References. Now since in my project, it doesn't call functions from the ForTest.dll, so it won't exactly affect my build process. Then the project builds successfully and runs fine.
I have tried looking at the build log, in detailed mode, for an error
message, but cannot find anything obvious.
When building a solution with several projects, and set the log in Detailed mode, it's easier to get lost in the hundreds of build logs. Since the yellow icon only displays for one project, you can right-click the project=>rebuild to build the project, it makes the message in build log more clear.
Or just use the Error List window as I suggest above to check the warnings and errors instead of hundreds of logs during Trouble-shooting.
In addition: If you can't find any info in Error List window, then maybe the reason why the yellow icon occurs is because VS didn't load the project well. Please try right-click the project=> unload and reload the project in solution explorer. If it persists,close all vs instance and delete the .vs folder in solution directory, and restart vs.
According to Microsoft, these yellow warning signs get added for every new reference and then removed once the reference is successfully added (=assumed guilty until proven innocent). If some yellow warning remains in the solution explorer, VS knows only that that reference is missing, but doesn't know why and can therefore not display a warning message in the Error window.
Not being able to find out why there is a warning sign is very annoying. The problem was reported, but Microsoft's standard response is: "This problem seems not to be requested enough to be resolved, but if you like, you can contribute your own solution."
So if you read so far, can you please go to developercommunity.visualstudio.com: tell me what's wrong with the reference 2 and vote this issue up, telling MS they should indeed fix this.
After spending hours trying to solve a none existing error, I gave up and closed VS. When I started it again, the problem was gone.
These errors also occur when adding a NuGet package that is not compatible with the current .NET (such as .NET Framework app under .NET Standard or .NET Core, or a .NET version such as referencing .NET Framework 4.8 library from an older .NET version).
Check that the package dependency is the same as the project you're working with.
It could also mean that the third party assembly you have on your machine is not registered in the gac and hence not being found. For older projects mostly if I have to hand copy over the dlls, I will then register them with this powershell script in the directory they reside in:
gci *.dll | % { gacutil /i $_.Name }

A dependent dll was not found

My app does not run on "Release x86" when running the app it crashes immediately after the splash screen. Output shows the following exception:
The program '[8204] dfz.exe' has exited with code -1073741515 (0xc0000135) 'A dependent DLL was not found'.
It also tells me the module is build without symbols, however in build settings I have set debug info to Full.
The first time I build the app for the Windows Store it built correctly and I also published that version to the store. When I did a manual rebuild to check if ads where inserted correctly it would not run.
However, I can run the app on ARM and X64 with no problems on release. Only x86 with .Net native toolchain will throw the missing dependant DLL.
What I have tried so far:
Created a new project, Added all my files and Nuget packages, No dice
Removed and updated all my existing references.
Tried to debug the release version so i can find out what DLL is missing from the package. However it keeps telling me there are no symbol files.
I am looking for any suggestions I can try because I am really at a loss here of why it will not run on x86.
Edit:
A blank UWP project also returns the DLL error when i run it. It looks like i have a broken development environment.
Edit2:
Just did a remote debugging session to another laptop and the app worked with no problems. So the problem is an environment related issue.
Could one of the projects in your dependencies be configured specifically for x64?
Another thing to check is that one of your projects is not set to build for that configuration (I vaguely remember some problem I had years ago that sounds kind like your situation ... although not for windows store apps ... and it turned out one of my projects wasn't set to compile for the configuration I was selecting ).

Visual Studio C# debugger - the breakpoint will not currently be hit

I know that this question has been asked several times, and many people here have suggested different answers. Though none of them are working for me.
I created a Windows Forms application with Visual Studio and .NET framework 4.0 and added a breakpoint. However, when I debug the application, an exclamation mark appears on the breakpoint and it says..
The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: conditional compilation or compiler optimizations.
I have tried out several suggested solutions
Cleaned the project
Deleted the pdb
Checked the configuration and ensured that it is debug
Set the debug configuration from "x86" to "Any CPU"
Tried creating project from scratch
Tried re-installing .NET framework
Removed temporary ASP.NET files
However, none of them seems to be working. I was able to debug my projects with breakpoints before and for some reason, something happened and I am not able to debug the projects any more. What should I look out for or fix to resolve this issue?
Probably your breakpoint is in a project which is not dependent on the "startup project". Implicitly these projects are not compiled on Run (button F5).
Go to: menu Tools → Options → Project and Solutions → Build and Run → uncheck first check box (only build startup projects and dependencies on Run).
I recently had this problem and it stumped me for a while. Ends up I had inadvertently switched my build configuration away from DEBUG to another configuration that was more optimized and did not "Define DEBUG constant": Project > Properties > Build > (first check box).
This may also happen if other projects in your solution are set to configurations other than DEBUG, usually accidentally, in the Solution Configuration Manager.
In Visual Studio go to the menubar, menu Debug → Windows → Modules, find the assembly your code is located in and check the Symbol state. Chances are you're having Visual Studio loading a different version not matching your PDB files.
I had the same problem here...
I was using Visual Studio 2005 - Professional Edition, and my problem was when I tried to breakpoint a Windows Forms application.
I've searched in many forums on the Internet, and I hadn't found any answer.
But the solution for this problem was easier than I had expected. Just right click on a Visual Studio shortcut (or .exe) and unmark execute in compatibility mode.
Your best option is to create a new project. Then import all the files in the previous project, including your forms if any.
You are now set to OK to continue.

Unable to open a windows form during debugging in VS2010

I am debugging a windows application in visual studio 2010, the application was developed and upgraded from .net framework v2 and VS 2005.
Originally, windows forms could be open on debugging mode. However, several times later without editing (as I was just tracking possible bugs before fixing), those forms become unable to open. Whenever, I tracked the bugs until the code which shows the form, then the debugger will just stop tracking without any messages. Does anyone know what problems could cause this situation? Thanks a lot.
Usually if you are unable to debug step into code then this usually indicates that there is no debug information available due to missing source and/or a missing debug .pdb file for that item.
Check the build configuration to ensure that you are attempting to debug a debug build, it is easy with solutions containing multiple projects to accidentally set the configuration manager to build a project in release mode, whilst the project that you're stepping from is in debug mode.
Also in multi-project solutions check that you are referencing the project and not the project output where required, otherwise setting the configuration manager to build a project in debug mode will have no effect if you're referencing a release build output for that project.
If the Winforms reside in a third party DLL then ensure that you have referenced a debug version of the library before attempting to debug.

VS 2010 Debugging old build

I have a visual studio 2010 web project that when I publish it in debug mode the application works fine and is the latest build.
However, when I try to click the play button/debug mode (in the same build configuration as what I published in) the assembly version is older than the most current one. As mentioned, this is a asp.net application using a c# class library as a reference (also in the solution) and I am debugging using Visual Studio's built-in web server.
I've tried everything I could think of at first in all different combinations as follows:
Clean solution
Clean each individual project
Build solution
Build each individual project
Rebuild solution
Rebuild each individual project
I tried to use a different browser and cleaned my cache as well.
Has this happened to anyone? How can I correct this issue?
It is most likely not set to build. To test this, try build then debug and see if things work. If so, then it is definitely not set to build.
To solve this, open up the Solution Properties. Go to Configuration Properties >> Configuration. Then run down to the project in question and check the Build checkbox. You will then be able to debug again.
This one bit me when a coworker decided the build of the UI was taking too long for his testing and removed it from the build. After discovering the issue, I had him create a separate solution to test in isolation. Yes, multiple solutions can contain the same project(s).
did you try deleting your bin and obj folders and removing your assemblies from the GAC? I would guess that THIS is the problem.
Don't forget to clean your Temporary ASP.Net (c:\WINDOWS\Microsoft.NET\Framework[version]\Temporary ASP.NET Files) files.
After that, do a rebuild and try.
Also, for local development, if you can, then do not GAC assemblies. GAC them while deploying to integration environment. THis will help speed up development a bit.

Categories

Resources