Visual Studio 之外的 AccessViolationException? [英] AccessViolationException outside Visual Studio?
问题描述
我正在开发一个使用非托管 C++ 库的小型 C# winforms 应用程序.我无权访问此库的代码.
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 类库并使用该类库.这没有帮助,我仍然有 AccessViolationException.
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:
工具选项调试一般
并禁用:禁止对模块加载进行 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屋!