ERRORS & DEBUGGING >> COMMON CAUSES OF THE INFAMOUS C5 ACCESS VIOLATION EXCEPTION
Eric den Doop
Eric den Doop
I'm listing some common causes of the infamous C0000005 error (AKA C5 error or Access Violation) below.
resident virus scanners
I advise only to use virus scanners that allow you to exclude certain files, folders or file types from the scan process. Always exclude DBF, FPT, CDX, DBC, DCT and DCX files. You may want to check the following article:
HOWTO: Optimize Visual FoxPro Applications While Using Norton AntiVirus
poor hardware/drivers (often network adapters)
Update the drivers or replace the hardware. I'd only invest in 100mb or gigabit network adapters.
ActiveX controls (OCX)
corrupt index file
corrupt memo file
dangling object references
RETURN inside WITH ... ENDWITH
corrupt resource files (foxuser.* / SYS(2005))
Shutdown your app or VFP and remove the foxuser resource files. These files are recreated automatically the next time you start your app/vfp. Read this article to learn more about trouble shooting file corruptions.
HOWTO: Troubleshoot to Resolve Suspected Corruption
HP LaserJet 4000 driver:
Here's some documentation:
PRB: Memory Error with HP LaserJet 4000 TN PCL 5e Driver
Sometimes it helps to remove the printer setup information from the report files. Here's some info on how to do that:
HOWTO: Clear Report TAG, TAG2, and EXPR Fields Using .pjx Hooks
If you're using VFP8 or later, you can prevent VFP from storing printer info in the report files. To do so, uncheck the "Save printer environment" option on the Reports tab of the VFP Options dialog.
The Microsoft KnowledgeBase contains quite a few articles related to the C5 error:
Lots C5 errors are fixed by the VFP Service Packs. Make sure you're using the latest Service Pack. For VFP6, it is SP5 which can be obtained here:
For VFP7, it is Service Pack 1:
For VFP8, it is Service Pack 1:
For VFP9, it is Service Pack 1:
Also check out Steven Black's website:
And Calvin's weblog:
@ 11/28/2009 9:03:00 PM
I found this guide very useful. May I contribute another cause ?
This is in vfp7 - I have not yet tested in vfp9
In a grid control displaying character fields from a table, if one of the defined display fields is defined as a character function that happens to exceed 254 characters, the result displays ok until you scroll into the over-sized field, whereupon you get an error 'String too long to fit' followed by C000005 and even worse, the index of the table is truncated to zero bytes.
CREATE TABLE webrefs (graphpath C(250),graphic C(100),htmlref N(6))
INDEX ON htmlref TAG webref
In a grid for browsing the table, one column controlsource is defined as (RTRIM(graphpath)+RTRIM(graphic))
Thanks to todays penchant for web pages to have descriptive captions of easily 250+ characters, the result exceeds 254 characters and you get a C0000005 error. Why the CDX file is corrupted at the same time is a mystery - possibly an overflow. I assure you that if the table is browsed in a grid, but the offensive line is not reached, no error occurs and no cdx corruption happens.
@ 12/3/2012 2:20:44 PM
add: calling another BROWSE out of the current BROWSE.
Enter the code shown: