Visual Studio 无法使用调试器 (AccessViolationException).以随机顺序执行的代码 [英] Visual Studio unable to use debugger (AccessViolationException). Code executing in random order

查看:43
本文介绍了Visual Studio 无法使用调试器 (AccessViolationException).以随机顺序执行的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

截至今天,我无法再使用 Visual Studio 调试任何 c# 代码.如果我使用调试器,可以命中断点,但是一旦执行暂停,麻烦就开始了.按 Step Into 或 Continue 通常会生成 AccessViolationException 表示内存已损坏并终止当前请求.如果我再运行一个 Web 请求,我将得到一个 SEHException(发生在未知模块中).

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).

更奇怪的是,如果 AccessViolationException 没有触发,显示下一条语句的程序计数器会随机跳转.然后以随机顺序执行代码!(直到它崩溃).

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
    }
}

已删除 VS 缓存、删除 .suo、清理并尝试安全模式.一个可能的怀疑是这是在 Windows 10 预览版机器上,上周有更新.我真的不知道还有什么地方可以确认它,或者在不重新映像机器的情况下修复它.

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.

推荐答案

Changeing from Any CPU to just x64 在我的Hello World"测试项目中为我解决了这个问题.

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. 将项目中的所有库更新为 x64,而不仅仅是 Web 项目.
  2. 在 VS2013 中启用 64 位 IIS express 工具 >选项 >项目&解决方案网络项目 >使用 64 位 IIS ...
  3. 通过控制面板安装 Internet Information Services Hostable Web Core(打开或关闭 Windows 功能).在我这样做之前,我会在以 HttpException (0x80004005): Specified argument is out of the range of valid values 的形式启动 64 位 Web 项目时收到错误消息.安装 HWC 修复了它.
  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.

这篇关于Visual Studio 无法使用调试器 (AccessViolationException).以随机顺序执行的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆