Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
ERRORS & DEBUGGING >>  COMMON CAUSES OF THE INFAMOUS C5 ACCESS VIOLATION EXCEPTION

  Eric den Doop
  Where is Eric den Doop?
 Houten
 Netherlands
 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: http://doughennig.blogspot.com/2006/04/dont-return-inside-with.html

- 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:
http://support.microsoft.com/search/default.aspx?Queryc=C0000005...

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:
http://msdn2.microsoft.com/en-us/vstudio/aa718363.aspx

For VFP7, it is Service Pack 1:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=B1BFB6C2-261E-4B7D-8838-8DCD5478A9EB

For VFP8, it is Service Pack 1:
http://www.microsoft.com/downloads/details.aspx?FamilyId=018705E6-DF6A-4695-965E-459FE5A761F7&displaylang=en

For VFP9, it is Service Pack 1:
http://www.microsoft.com/downloads/details.aspx?FamilyId=1C06E35D-10A2-4A05-84FC-495B3A73ECF7&displaylang=en

Also check out Steven Black's website: http://fox.wikis.com/wc.dll?Wiki~c0000005Error~VFP

And Calvin's weblog:
http://blogs.msdn.com/calvin_hsia/archive/2004/06/30/170344.aspx

FEEDBACK

David Hall @ 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.

an example
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.

David Hall

Martin Brunner @ 12/3/2012 2:20:44 PM
add: calling another BROWSE out of the current BROWSE.



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: