未处理的异常:访问冲突 [英] Unhandled Exception : Access Violation

查看:68
本文介绍了未处理的异常:访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试时遇到未处理的异常:访问冲突"的问题如何解决,请帮帮我


谢谢
AJ

While debugging im getting "Unhandled Exception : Access Violation" How to solve it please help me


Thank you
AJ

推荐答案

首先,您是否使用了调试器?几乎在所有情况下,它都可以查明问题所在.还有问题吗?

处理所有异常,至少在每个线程的堆栈顶部.这将为您提供足够的信息来解决该问题.如果仍然无法解决,请转储异常信息,堆栈,查找发生代码的行,发布代码的相关部分(注释抛出异常的行)并进行异常转储.

不要阻止任何异常向上传播,否则您将很难找到目标.当您确实需要处理异常并阻止其传播时,通常会将此规则排除在少数情况之外,通常是作为一些您的补丁无法访问的第三方代码的变通办法.

您只能在每个线程的顶部和主UI周期中阻止异常传播,始终记录异常信息(如果在UI线程中,则将异常信息显示在UI中).这样做是为了避免应用程序终止.在所有情况下,都应具有异常转储.

如果您在获取此信息后无法找到并解决问题,则将其发布并询问后续问题.

—SA
First of all, did you use debugger? It will pin-point the problem in almost all cases. Still have problems?

Handle all exceptions, at least on top of the stack of each thread. That will give you enough information to address the problem. If you still cannot solve it, dump exception information, stack, find out code lines where it happens, post relevant part of code (comment the lines where exception is thrown) and exception dump.

Don''t block any exceptions from propagation up the stack, otherwise you will have huge troubles finding the ends. There are some rare exclusions from this rule when you really need to handle exceptions and block its propagation, usually as a work-around of some 3rd-party code inaccessible for your patch.

You can only block exception propagation on the very top of each thread and in the main UI cycle, always logging exception information (and presenting it in UI if it is in the UI thread). This is done to avoid termination of the application. You should have the exception dump in all cases.

If you cannot locate and fix the problem after you get this information, post it and ask follow-up Questions.

—SA


您可能想使用以下参考为程序添加一些调试功能:
Visual C ++中的异常处理 [ _set_se_translator [ DebugBreak [
You may want to use the following references to add some debugging functionality to your program:
Exception Handling in Visual C++[^]

_set_se_translator[^] - allows you to convert an access violation into a C++ exception - it''s usually a good idea to preallocate a buffer for exception information on a per thread basis to avoid calling the runtime libraries during this conversion.

Possibly calling DebugBreak[^] as appropriate.

This usually facilitates more efficient debugging - especially if there is a lot of concurrent activity in your program.

Best regards
Espen Harlinn


这篇关于未处理的异常:访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆