'Access violation' when running application through Visual Studio

可紊 提交于 2019-12-12 13:20:24

问题


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'.

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.

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?


回答1:


Can I ignore this error since the app works fine when built?

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.

If not, what could be the potential issue and how can I solve it?

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.



来源:https://stackoverflow.com/questions/31804358/access-violation-when-running-application-through-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!