程序随机获取System.AccessViolationException [英] Programs randomly getting System.AccessViolationException
问题描述
类型'System.AccessViolationException'的未处理的异常
发生在System.Windows.Forms.dll中
附加信息:尝试读取或写入受保护的内存。
这通常表明其他内存已损坏。
它不是我的代码错误。下面我做了一个简单的测试。请注意,我没有从此应用程序引用System.Windows.Forms。
using System;
使用System.Collections.Generic;
使用System.Linq;
using System.Text;
命名空间ConsoleApplication2
{
类程序
{
static void Main(string [] args)
{
列表& int> testing = new List< int>(); (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。
Okay so I have been having a lot of issues with debugging. I'm using VS2013 Pro and Windows 8.1. Both are up to date. The issue is, when I start debugging, half the time it throws this error:
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.
Its not my code's fault either. I made a simple test as an example below. Note that I am not referencing System.Windows.Forms from this app.
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();
}
}
}
I have no idea what's causing this. It will work if I click okay and run it again, most the time. Occasionally I have to do it twice.
Any ideas?
Stack trace:
Changing the Platform Target to x86 works for me, It came to a point that stepping through the code was impossible without the forementioned Exception. I run Win 8.1 64-bit and Visual Studio 2013.
这篇关于程序随机获取System.AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!