My program worked fine up until 30 minutes ago when it just would not launch. I didn't change any code and all settings are the same. When I try to launch my application through visual studio it just does what it usually does then says "Ready". Nothing shows. If I try to debug the code by breaking it somewhere, the breakpoint says "The breakpoint will not currently be hit. The source code is different from the original version." Also visual studio freezes if I leave the supposedly running program going for longer that about a minute, then I have to end the visual studio task. There really isn't any code that I can show you for this.
What is going on and how can I fix it? Is my project corrupt somehow?
If this happened to me I would do:
Check Configuration ( Debug vs Release vs other)
Check Platform (AnyCPU or ....)
Make sure that they both are Debug and AnyCPU
Save solution
Clean Solution
Build each project starting with the one that has no dependencies
** UPDATE **
You posted this message
"0 succeeded, 0 failed, 1 skipped" –
When you Clean, there should be no skipped projects in the process of rebuilding
Related
Here's what I get when I click on Step Over
Here's what it is before clicking on Step Over
What I am expecting is for the debugger to step over onto line 10, but it just keeps exiting the debug mode, as can be seen on the last line of the debug console.
I have tried the following:
Restarting Visual Code
Deleting and reinstating the .vscode folder conatining launch.json and tasks.json
Uninstalling and reinstalling VS Code
Building new console and debug files and starting from a fresh
Removing settings.json file
Moving VS Code to application folder (and then reinstalling again)
Checked same code files with someone else's VS Code and their debugging mode allows step over and works as expected.
Is there any potential fixes I am missing or any thing that can be spotted as wrong on the screenshots? Appreciate any help.
I'm running this Mac OS Big Sur v11.1 if that's relevant.
EDIT: When I run this code in Visual Studio 2013, the debugger is showing Utc, not Local. It's a bug in Visual Studio 2015 Debugger.
EDIT: Have taken the code and put in stand-alone console app, but cannot reproduce in either version of VS. Bummer.
Can someone explain to me how what you see in this screenshot is possible?!
On line 298, endingTimePeriodStartDate is redefined as its Date value but set to DateTimeKind.Utc.
On Line 300, if endingTimePeriodStartDate is not actually DateTimeKind.Utc, an exception is thrown.
The debugger breakpoint on line 305 is hit, meaning the exception on line 302 was not thrown, meaning endingTimePeriodStartDate.Kind == DateTimeKind.Utc
(I also did a System.Diagnostic.Debug.WriteLine(endingTimePeriodStartDate.Kind) before line 305 and it prints “Utc” in the Output window).
When I look at endingTimePeriodStartDate in the Locals and Watch debugger windows, and when I mouse hover over the variable, the Kind property shows DateTimeKind.Local
Usually the debugger will show wrong line numbers, and go into old code if it is running a different version of the dll (a former version) than the one that your code is showing. This happens
when there is some kind of caching
when the former running version wasn't closed correctly, or is still running in another process.
when the Visual Studio is not pointing to the correct code
Usually to fix this, you should:
(Start by trying only a "clean" and "rebuild")
Stop all running or debugging Visual Studio projects.
Close all your Visual Studio solutions and windows, so that Visual Studio is not running.
(If next step doesn't do the trick, then the next time around reboot your computer as well before going on to next step)
Re-open only the solution you need to run. Hit "Clean solution". Then "Rebuild solution".
Check if this fixed the problem.
Manually delete the bin folders: (if the clean/rebuild didn't work)
5.1 If your afraid, backup your whole source directory. After everything works, delete the backup...
5.2 manually go into the dependent projects (that are referenced in your "wrong code showing" project) and in each one of them, go into the obj and into the bin folder and delete everything that was automatically created from there - in other words, everything that you did not put there manually. Usually that's everything. Don't worry, visual studio will re-create the Debug and Release directories and fill them up.
Delete the obj and bin of your project as well.
Rebuild everything.
As of today I can no longer debug any c# code using Visual Studio. If I use the debugger, breakpoints can be hit, but as soon as execution has paused the trouble begins. Pressing Step Into, or Continue will normally generate an AccessViolationException saying the memory is corrupt and kill the current request. If I then run a further web request I will instead get an SEHException (occurred in Unknown Module).
It gets even more odd, in that if the AccessViolationException doesn't trigger, the program counter that shows the next statement jumps randomly. Code is then executed in random order! (until it crashes).
If no breakpoints are hit then the app will run in debug mode just fine (even with the debugger attached).
I am confident it's not a code issue. I can actually reproduce the access violations with a new project and the following code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
Console.WriteLine("Access violation"); // This will throw if breakpoint set
}
}
Have deleted VS cache, deleted .suo, cleaned, and tried safe mode. The one possible suspect is that this is on a Windows 10 preview machine, and there was an update last week. I am not really sure where else to go with this to confirm it, or fix it without reimaging the machine.
Changing from Any CPU to just x64 resolved this for me on my "Hello World" test project.
To get working on my original project, which was actually a web project, I had to take a few extra steps.
Update all libraries in the project to x64, not just the web project.
Enable 64 bit IIS express in VS2013 Tools > Options > Projects & Solutions > Web Projects > Use 64 Bit IIS ...
Install Internet Information Services Hostable Web Core through Control Panel (Turn Windows Features On or Off). Before I did this I would get an error when launching 64 bit web projects in the form HttpException (0x80004005): Specified argument was out of the range of valid values. Installing HWC fixed it.
Still none the wiser why any of this is happening, but at least I can debug projects again.
This exception appeared to start out of nowhere and certainly caused me some headache, but I was able to resolve my issue by doing the following:
Go into the properties of the affected Projects
Go to the Debug Tab
Uncheck "Enable native code debugging"
i recently installed VS 12 Service Pack 1.
Since then, i noticed Visual Studio doesn't compile my project on start if changes were made.
Normally if you start (debugging) a project which has some changes, it recompiles it and starts then. But now, i always get debugging errors like "this breakpoint can´t be reached, because the source code is unequal to the runtime code" or whatever.
It´s annoying to recompile it manually always before starting - I always forget that :-/
Is there any option to fix this?
Can you check if the build on run option is set?
You will find it under Tools->Options->Project and Solutions->Build and Run.
I dont have a good answer as to why this would have been flipped just via installing the update1.
I think that you should enter the Solution's Property Pages (by right clicking the solution in the Solution Explorer pane) and setting the 'build' check-box of the relevant project.
I have C# application built in VS2010. Recently I changed something in project properties and now I have strange problem:
I can't start debugging of my application (F5). When I press F5 project compiles but then nothing happens. Even if I put some dummy code to my program.cs main function ie MessageBox.Show() it's not executed.
I can build app using "Build solution", it compiles and executes with no problems
In project properties following options are enabled:
- Define debug consant
- Define trace constant
- Advanced bulid settings / Debug info - full
What should I change to be able to debug my app from IDE?
Try deleting .suo file. Make backup first!
Here is similar thread:
VS2010, F5 - Builds but doesn't run (WPF)
Shutdown and restart VS :) It's happened to me a few times before.