好吧,我在调试方面遇到了很多问题。我正在使用 VS2013 Pro 和 Windows 8.1。两者都是最新的。问题是,当我开始调试时,有一半时间会抛出此错误:
An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
这也不是我代码的错。我做了一个简单的测试作为下面的例子。请注意,我没有从该应用中引用 System.Windows.Forms。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<int> testing = new List<int>();
for(int i =0; i < 50; i++)
{
testing.Add(i);
}
for (int i = 0; i < 50; i++)
{
Console.WriteLine(testing[i].ToString());
}
Console.ReadLine();
}
}
}
我不知道是什么原因造成的。如果我单击确定并再次运行它,大多数情况下它会起作用。有时我必须做两次。
有什么想法吗?
堆栈跟踪:
最佳答案
将平台目标更改为 x86 对我有用,如果没有上述异常,单步执行代码是不可能的。我运行 Win 8.1 64 位和 Visual Studio 2013。
关于c# - 程序随机获取 System.AccessViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24294543/