转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
Delphi Access violations 问题的解决之道         ★★★★

Delphi Access violations 问题的解决之道

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2367 更新时间:2009/4/23 18:44:43
 

Your application will be shut down!

Page 1 : What access violations are and how to prevent AVs at design-time.

Access Violation, General Protection Fault or Invalid Page Fault, the name changes, but the nature of the error is always the same. Access Violation is a phrase that users of personal computers see when an application they are running tries to access storage that is not designated for their use - and crashes.

Access violation at address <HEX_value>
in module <Application.Exe>.
Read of address <HEX_value_2>

If Windows applications were able to write outside of its assigned storage area, it could overwrite other applications'''' or the operating system''''s instructions and data. If that should happen, the operating system would "crash" or close down in some way and you would have to reboot the operating system. For example, when a program error occurs in Windows NT/2000, Dr. Watson steps in and stops the program, taking some quick diagnostic stats, recording them in a text file.

Access Violations are some of the most frustrating errors encountered in Windows programming. The purpose of this article is to help you find the solution to your AVs with Delphi. To start with, access violations have nothing to do with Microsoft Access.

We can divide AVs encountered while developing with Delphi in two major types: runtime and design time.

   Access Violations at Design-Time
Design time AVs are experienced when starting and closing the Delphi IDE or building a Delphi project.

Hardware
AV messages that crop up while your computer is in operation can be generated by various different sources, including the system BIOS, the operating system or hardware driver routines. Some video, sound or network cards can actually cause AVs in Delphi. Why? Every card in your machine comes with device drivers. Depending on the manufacturer, the version of Windows, and the version of Delphi used you may experience problems. There are some steps that can be taken to help resolve these issues:

·  Take the steps necessary to verify that there are no conflicts between your installed devices.

·  Sometimes lowering the resolution will help stabilize a quirky video card driver.

·  Insure that if you are using a dual processor motherboard that the step revision for each processor is the same.

·  Always use the latest driver for all of the components in your system.

Software
Although Windows is the most popular operating system for Intel machines, due to the extreme fragility and bugginess of Windows, misbehaving applications can readily crash the OS (and the OS sometimes crashes itself spontaneously). There are ways that you can help your chances of having a more stable programming environment, which in turn will help to prevent certain AVs.

·  Although Windows 9X is quite popular, Windows NT/2000 has proven to be a much more stable environment for almost all Windows coding platforms.

·  Ensure that you have installed the latest service packs for NT/2000. With each service pack released, you will find that your machine will become more stable.

·  One excellent method of proactive error prevention is to always keep the current with all updates and patches for whatever edition and version of Delphi (BDE, ADO, ...) that you are using. Always have the latest patch for Delphi - the number of AVs, especially design time violations, will drastically decrease.

·  If you are getting random access violations in the IDE, you have most likely installed a bad component or package or a wizard that was not written/compiled for your Delphi version. Try uninstalling custom components one by one (or package by package) until the problem goes away, then get in touch with the component vendor regarding this issue.

·  Check to see whether if there is anything unusual installed on the machine with the program that crashes. Curious shareware utilities and beta products are AV favorites.

·  An access violation can also occur because a system setting is wrong. If you repeatedly encounter the same error message, record the details and call the company that makes the software that seems to be causing the message.

That is all I can suggest for design-time access violations, the rest of the article deals with run-time AVs and how to make sure your application will not cause them!

Your application will be shut down!

Page 2 : The most common run-time Delphi access violations and how to prevent them.

It happens with any software development: you write the application, test it, and send it out into the wide world. Then a user calls up to tell you that your pride and joy has fallen flat on its face.

You might want to consider compiling your application with the {$D} compiler directive - Delphi can create map files which can be a big help in locating the source of AV errors. The Project Options dialog box (Project|Options|Linker & Compiler) lets you specify all you need. For units, the debug information is recorded in the unit file along with the unit''''s object code. Debug information increases the size of unit file and takes up additional memory when compiling programs that use the unit, but it does not affect the size or speed of the executable program. The Include debug info (Project|Options|Linker) and Map file (Project|Options|Linker) options produce complete line information for a given module only if you''''ve compiled that module in the {$D+} state.

Access violations usually manifest themselves in only one aspect of the program. It is important to think about what the user was doing when the problem first occurred, and then work towards a solution from there. From the user''''s point of view, your application has made the user stop working, and the time spent telling you about the problem seems to be delaying you from fixing it. However, talking with the user is the only way you will find the problem and improve your application.

Now you will see how to easily find the exact routine, source code file, and line where an AV occurred when given nothing more than the crash address.

   ''''Search - Find Error...''''
When a run-time AV occurs, the error message your user gets, looks something like:

Access violation at address <HEX_value>
in module <Application.Exe>
Read of address <HEX_value_2>

If you have your application compiled with debug information in the Delphi IDE, you can locate the line of source code corresponding to the compiled code that caused the access violation.

Non-existing object
One of the most common causes of AVs in Delphi programming is the use of an object that has not yet been created. If the second address is FFFFFFF (or 0000000) you can almost bet you are accessing an object that has not been created. For example calling a method on a form that was not auto-created and is not instantiated by the code.

procedure TfrMain.OnCreate(Sender: TObject);
var BadForm: TBadForm;
begin
  // this will generate an AV
  BadForm.Refresh;

end;

Suppose that BadForm is listed in the "Available Forms" list in the Project Options window - forms that need to be created and freed manually. In the code above the call to Refresh method of the BadForm form causes an access violation.

If you have enabled the "Stop on Delphi Exceptions" in the Language Exceptions tab on the Debugger Options w

[1] [2]  下一页


[其他]手工升级ACCESS到SQLSERVER方法详解  [Web开发]把ACCESS的数据导入到Mysql中的方法详解
[系统软件]InstallShield Express for delphi制作安装程序定…  [常用软件]InstallShield Express制作Delphi数据库安装程序
[C语言系列]SQL Server连接ACCESS数据库的实现  [C语言系列]应用 SQLServer 链接服务器访问远程 Access 数据库
[VB.NET程序]WindowsForm登陆窗体的制作(Vb.net+Access)  [VB.NET程序]在VB.NET中使用MS Access存储过程 — 第二部份
[VB.NET程序]在VB.NET中使用MS Access存储过程 — 第一部份  [VB.NET程序]如何在Visual Basic 6.0 中连接加密的Access数据库
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台