Visual Studio 之外的 AccessViolationException?

发布于 2024-08-29 18:56:40 字数 432 浏览 1 评论 0原文

我正在开发一个小型 C# winforms 应用程序,该应用程序使用非托管 C++ 库。 我无法访问该库的代码。

如果我在 Visual Studio 中运行我的应用程序,请对库进行调用,发现一切正常。一旦我运行 CTRL + F5,我就会收到 AccessViolationException。 我做了一些测试,在 .NET 2.0 中创建了另一个 winforms 应用程序(其他应用程序在 .NET 4.0 中),但我没有收到 AccessViolationException。所以我想我应该在 .net 4.0 解决方案中创建一个 .net 2.0 类库并使用该类库。这没有帮助,我仍然遇到了 AccessViolationException。

尝试设置允许不安全代码、打开和关闭优化代码,但这没有帮助。 为什么退出调试模式后会收到 AccessViolationException?

谢谢

I'm developing a small C# winforms application that consumes an unmanaged C++ library.
I have no access to the code of this library.

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.

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?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮光之海 2024-09-05 18:56:40

我刚刚偶然发现了同样的问题。要在调试器中重现问题,我必须转到:

Tools\Options
调试\常规

并禁用:抑制模块加载时的 JIT 优化(仅限托管)。

当然,只有经过优化的代码才会出现这个问题。

I just stumbled upon the same issue. To reproduce the problem in the debugger, I had to go to:

Tools\Options
Debugging\General

and disable: Suppress JIT optimization on module load (managed only).

Of course the problem would only appear for a optimized code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文