本文介绍了通过Visual Studio运行应用程序时出现“访问冲突”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从Visual Studio中运行命令行应用程序时,一个命令总是失败,并出现以下错误:

When I run my command-line application from within Visual Studio, one command always fails with below error:

The program '[7316] MyProgram.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

当我调试代码时,这发生在最后一个执行行之后。意味着该应用程序可以正确执行其功能,但随后会崩溃。当我构建项目并在命令行中运行exe文件时,我没有收到任何错误,并且工作正常。

When I debug the code, this happens after the last execute line. Meaning the application performs it's function correctly but then crashes. When I build the project and run the exe file in the command-line I get no error and it works fine.

该项目使用第3方dll,而该文件又是AFAIK调用C或C ++ dll,例如。 .Net中未编码的内容。

The project uses a 3rd party dll which in turn AFAIK calls a C or C++ dll, eg. something not coded in .Net.

我的问题:由于该应用在构建时可以正常运行,我可以忽略此错误吗?如果没有,那么潜在的问题是什么,我该如何解决?

My questions: Can I ignore this error since the app works fine when built? If not, what could be the potential issue and how can I solve it?

推荐答案

我不会忽略该问题。如果您的应用程序在关闭过程中失败,则销毁对象并将句柄返回Windows(很可能是后者)可能有问题。

I wouldn't ignore the issue. If your application fails during closing, there is possibly something wrong in destructing the objects and returning the handles to Windows (most likely the latter). This might get you in a production scenario eventually.

如上所述,我认为释放句柄是个问题。如果您使用某些用C ++编写的第三方DLL,则可能存在问题。尝试设置一些日志记录,看看异常的堆栈跟踪是什么。这可能使您知道问题出在哪里。也许这甚至是一个问题,您都可以报告给DLL的供应商。

As said, I think releasing handles is the issue. If you use some third party DLL which is written in C++, possibly there is the issue. Try to set up some logging and see what the stack trace of the exception is. This might give you an idea where the problem is caused. Maybe this is even an issue you can report back to the vendor of the DLL.

这篇关于通过Visual Studio运行应用程序时出现“访问冲突”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:51