Visual Studio unable to use debugger (AccessViolat

2019-07-21 03:02发布

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.

2条回答
相关推荐>>
2楼-- · 2019-07-21 03:38

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.

  1. Update all libraries in the project to x64, not just the web project.
  2. Enable 64 bit IIS express in VS2013 Tools > Options > Projects & Solutions > Web Projects > Use 64 Bit IIS ...
  3. 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.

查看更多
Viruses.
3楼-- · 2019-07-21 03:51

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:

  1. Go into the properties of the affected Projects
  2. Go to the Debug Tab
  3. Uncheck "Enable native code debugging"
查看更多
登录 后发表回答