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 justx64
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.
x64
, not just the web project.Tools > Options > Projects & Solutions > Web Projects > Use 64 Bit IIS ...
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 formHttpException (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: