Visual Studio之外的AccessViolationException? [英] AccessViolationException outside Visual Studio?
问题描述
我正在开发一个小型C#winforms应用程序,该应用程序使用非托管的C ++库。
我无权访问该库的代码。
I'm developing a small C# winforms application that consumes an unmanaged C++ library. I have no access to the code of this library.
如果我在Visual Studio中并且运行了我的应用程序,则对库进行所有调用正在寻找。一旦运行CTRL + F5,我将获得一个AccessViolationException。
我做了一些测试,在.NET 2.0中创建了另一个winforms应用程序(其他在.NET 4.0中),但是我没有收到AccessViolationException。因此,我认为我将在.net 4.0解决方案中创建一个.net 2.0类库,并使用该类库。
If I'm in Visual Studio and I runt my application, do my calls to the library everything is working find. Once I run CTRL + F5 I get an AccessViolationException. I did some testing, created another winforms application in .NET 2.0 (others were in .NET 4.0) and there I don't receive the AccessViolationException. So I thought i'd create a .net 2.0 class library in my .net 4.0 solution and consume that class lib. This didn't help, still I had the AccessViolationException.
尝试设置允许不安全的代码,打开和关闭优化代码,但这无济于事。
退出调试模式后,为什么会出现AccessViolationException?
Tried setting allow unsafe code, optimize code on and off but that didn't help. Why am I getting the AccessViolationException once I'm out of debug mode?
谢谢
推荐答案
我偶然发现了同一问题。要在调试器中重现该问题,我必须去:
I just stumbled upon the same issue. To reproduce the problem in the debugger, I had to go to:
工具\选项
调试\常规
Tools\Options Debugging\General
并禁用:禁止在模块加载时进行JIT优化(仅受管理)。
and disable: Suppress JIT optimization on module load (managed only).
当然,问题只会出现在优化的代码上。
Of course the problem would only appear for a optimized code.
这篇关于Visual Studio之外的AccessViolationException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!