Fatal error: Exception code=C0000005 and VFP9

Hello experts

I have an application that works fine (was developed in VFP9).  However, once in a while, when I install my application in a new customer/computer, I have the message:

Fatal error: Exception code=C0000005

Right at the beginning of the application (it doesn't even show the foxpro screen or anything else, just the message and then the program aborts).  I checked again virus, chkdsk, etc. and nothing works.

Sometimes it occurs in XP, sometimes  W7.  Some of those machines are brand new.  The same disk that I use to install my app in one machine that works fine, is being used in another machine that occasionally doesn't work.


Thanks in advance.

Grijalbo.
grijalboAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
This has nothing to do with the computer. It might be a printer driver, ban index, incompatible code page or system language regional setting.

Try to put breakpoints and find out where exactly it is doing so.

Completely reindexing the files might help. Deleting corrupted foxuser.dbf and foxuser.fpt might also help. Back them up first.
Gary2SevenConsultantCommented:
I  with captaincyril, delete the fox user fie.

Other thing is to check the error log, vfp9err.log, which should be next to the DLLs, normally c:\Program Files\Common Files\microsoft shared\VFP

That may give you an error line, you can then trap that in a TRY / CATCH block and trace the error.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
From all the applications that I have built, I found workarounds or fixed the problem with the following:

Install a service pack
Delete foxuser
Complete delete index and reindex each table
Installed a new printer driver
Changed the regional settings or code page to match system.

There are hundreds of possible problems if you search for C5 error on Google. We need to narrow down the search in order to help you.
5 Ways Acronis Skyrockets Your Data Protection

Risks to data security are risks to business continuity. Businesses need to know what these risks look like – and where they can turn for help.
Check our newest E-Book and learn how you can differentiate your data protection business with advanced cloud solutions Acronis delivers

pcelbaCommented:
This behavior occurs on computers where are some components (DLLs) which do not match your VFP version. Look e.g. into folder C:\Program Files (x86)\Common Files\microsoft shared\VFP or even in C:\Windows\System32 etc.

It should not happen if you place all necessary DLLs into the app folder. The list of necessary files is here: http://fox.wikis.com/wc.dll?Wiki~VFP9RuntimeFiles~VFP
Olaf DoschkeSoftware DeveloperCommented:
If you provide your foxuser.dbf with the setup, because it contains some settings, it could easily cause the C5 errors, that's true. Either provide no foxuser.dbf and let the exe create one, or even include a config.fpw into compilation, which prevents creation of a foxuser.dbf via the config.fpw line RESOURCE=OFF

Especially when installing to program files, no write access is given and no foxuser.dbf can be created. That would not cause a C5 error, though.

What runtime files do you include in your setup?
As you mentioned this happening on brand new computers, you may rely on something installed with other software, which you would perhaps simply need to add to your setup.

Bye, Olaf.
grijalboAuthor Commented:
Thanks for your answers:

To   CaptainCyril : your sugestion can not be used ("...reindexing the files might help. Deleting corrupted foxuser.dbf and foxuser.fpt....."). My app doesn't work with DBF tables, only with SQL (Express 2008) tables and I already install my app without Foxuser.* files.

To   Gary2Seven: "......check the error log, vfp9err.log,.........", regretfully, only shows the error, plus date, hour and nothing else. Don't even the name of the program that made the  first call. Not big help on this file. In regards to TRY and CATCH, I am trying to use that, but so far I can not "catch" that elusive error.

To  pcelba: ".....place all necessary DLLs into the app folder.............", Already try that and it didn't work.

Still to try:  replace printer driver , and find out if my app is expecting some "hidden" DLL from Foxpro  ( GDIPLUS,...., etc.). I would say that out of 30 installations, one of them has de C5 error, the rest of computers works fine (keep in mind that it is same software without changes). I "googled" C5 error and there are many possible causes (perhaps hundreds), I can not try all of the possible solutions.  The only possible solution is keep trying with TRY and CATCH. I was thinking that perhaps there is a more efficient way to solve this problem.
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
Can you put breakpoints or milestones?

For example: Connecting to database, Writing log, deleting temp files, ...
This way you can know what the software is doing to find the source of the problem. So instead of hundreds of problems you can narrow it down to 2 or 3.

In my last C5 error, I managed to know that it was an EditBox with Chinese characters on an English-US OS language that caused the application to crash.
pcelbaCommented:
If the C5 error rises right at the beginning then it cannot be caused by the app itself or by printer driver etc.

VFP has no hidden DLLS but you have to inspect your computer for all VFP related DLLs occurence. E.g. old version of VFP9R.DLL in Windows\System32\ folder causes C5 error.
The list of DLLs used by VFP is in my previous post. It does not contain file sizes but you may post file sizes and versions of DLLs from your PC.

Also, you could install the VFP run-time from this link http://archive.msdn.microsoft.com/FoxPro/Release/ProjectReleases.aspx?ReleaseId=125. I am just not sure if it deletes possible occurences of the old versions residing on PC. Probably not. You'll get the correct DLL versions by installing the above run-time at least.
Olaf DoschkeSoftware DeveloperCommented:
Again: What runtime fiels DO you include in your setup?
If you don't include the C runtime you depend on whatever is already on the system.
If you don't include the gdiplus.dll you depend on what is already on the system.
And that can crash.

You are explicitly allowed and it is explicitly recommended you install not only the core VFP runtime vfp9r.dll, but also all the related DLLs.

Pavel has pointed you to a runtime installer suite of which you can pick the appropriate one having the right SP revision. Just see what Version() says, the last number is what is meant as the Revision in the link pavel gave you.

As you don't install foxuser.dbf, it's recommendable you suppress it's generation, too. Write a textfile with RESOURCE=OFF as it's only line, name it config.fpw, include it to the project in text or other files and right click on it to untick the exclude context menu item. If that is unticked the file is not excluded from compilation into the final EXE. If you then build you have an exe that won't try to create a foxuser.dbf file and if that is by chance the reason you get your c5 error in some cases, that would resolve it.

In the normal case the OS restricts writing the foxuser.dbf right besides the EXE, if you install into program files, but it is instead written into a user directory. If that is also suppressed by group policies eg, then that could cause a c5. That would also explain, why it doesn't happen always and only at some clients.

Bye, Olaf.

PS: Yes, there are many reasons for a C5, but very few for a C5 right at the start, even before any of your code lines run. Put a messagebox as your fist line and see if that executes. If the C5 error is before, the only reasons are runtime mismatch or a problem in foxuser.dbf usage or creation. There is nothing else done, before your code starts, than loading the runtime(s) and creating/using foxuser.dbf.
grijalboAuthor Commented:
Thank you again for answers

I will try your suggestions.  It will take some time before I have the answer, I can not reproduce the problem in my computers, and access to my customers' computers is hard (they are in another countries, the only way is remote desktop), As soon as I have something I will let you know.
Olaf DoschkeSoftware DeveloperCommented:
Take your time.

The things you can do without knowing the result of the "Messagebox-Test":

1. create a config.fpw file with RESOURCE=OFF, add it to the project and include it in the compilation into the EXE. As you don't use foxuser.dbf, that's a reasonable thing to do and also removes one possible reason for an error.
2. Check the Runtime files version(s) of the DLLs you bundle in your setup with the Version() your IDE shows. It's verifyable by the version the Windows Explorer shows in file properties of vfp9r.dll, vfp9t.dll (eventually) and vfp9renu.dll, too, which must match what VERSION() shows.

This is an overview over all the files of which you might have forgotten the one or other: http://fox.wikis.com/wc.dll?Wiki~VFP9RuntimeFiles

Also: Checking VERSION() at runtime you see what runtime version is really loaded and _VFP.Servername will give you the main runtime DLL name used. But that again is a step to take at the client installation.

I'm sure you reveal something.

Bye, Olaf.
pcelbaCommented:
My closing recommendation:
Split points to
https:#a38541113
https:#a38541152
https:#a38543085
https:#a38547996
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
To the moderators. The C5 error is not something specific or can be easily solved. I second pcelba's suggestions to split points because these are the most common solutions to the C5 error.
pcelbaCommented:
@eenookami:

Every discussion about C000005 error in FoxPro is worth to read as this unhandled exception can have thousands of possible reasons... and this knows every Visual FoxPro developer.

All what was written in our posts is true and could help others to understand the foggy C000005 reasons. Unfortunately, grijalbo stopped responding and did not post the final resolution.

But are you sure just this final resolution would tell others what should they fix in their own applications to avoid C0000005 error? Not at all but others can try what we have recommended during the three days in the discussion.

So we have condensed our decades accumulated knowledge into three days and you now simply say "delete everything"...?

OTOH, it could also seem we are just points collectors... So in such case select the post hppps:a#41696557 as the answer please but don't delete this question.

TIA
Pavel
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
I second pcelba.

Keep the question. Don't give us points if that satisfies you eenookami. Your words should be directed to Microsoft for their vague handling of C000005 errors.

Captain
harsoyo -Commented:
Dear all Fox Users
my app appear to those error c5

i try to trap step by step, error appear because  one of my table missing field in my grid.

in my programming error appear when the routing program "thisform.grid1.refresh"

i am no need  reinstall my VFP9, DLL or anything

Matur nuwun
pcelbaCommented:
We cannot help as we don't know your code, your VFP version, your conditions. Just read all the posts here and try to implement all hints.

MSDN Archive never more offers VFP Runtime download so here is the working link for VFP runtime downloads:  http://www.foxpert.com/download/runtime.html
Olaf DoschkeSoftware DeveloperCommented:
Just to add once more: C5 is just a headline. It categorizes this as an error the VFP runtime is not able to handle itself, no VFP error that has a specific error number, no specific reason for it. So don't think when you find someone stating he found the reason, the same solution applies to you. You get a good hint in vfp9err.log stating the line which last executed. That can be a hint about a corrupt file like dbf or frx, but the error rarely is that line itself, it just has the bad luck of acting on something broken. Could be using a method of an object still in memory, though it should have released 100 lines of code back in some other class that ran before.

C5 error even is a C++ concept, not a VFP one, it's access violation accessing invalid memory buffer, for any reason, eg a pointer in a dbf pointing to a non-existing offset of an FPT file. A memory address an object instance once was existing - anything.

https://blogs.msdn.microsoft.com/calvin_hsia/2004/06/30/what-is-a-c0000005-crash/
https://stackoverflow.com/questions/17168982/exception-error-c0000005-in-vc

You can't suppress this or catch it in a try..catch. Some reasons are the VFP runtime not expecting certain corruption in files, no pointers to non-existing FPT file portions, for example. It's just a made up example anyway, but all you can do is verify what's been acted with the line of code, so this is just a starting point for an investigation of the involved PRG or SCX or VCX, involved open tables and reports and much more code and files up to the point of everything that ran previously and led to the situation. Even simpler errors the ones having a native VFP error number and a distinct simple explanation often need more than fixing that single line of code.

If you never debugged code, a C5 is a good reason to start. Once you know where it happens reproducible set a breakpoint for example in some click leading there and go through what happens step by step. And don't wait for the C5 to happen, the seed of the error is typically planted earlier, it might even already exist when you start into single-step debugging. It can be a buffered record that is just committed when a dbf is closed because another one is opened, and then you should not only suspect the newly opened dbf. So this really needs experience of debugging in general, which you never get, if this is the first hard error challenging your bug fixing.

Know your FoxPro, use coverage logging to see much more than just the last few lines of code executing up to the C5 error incident. Have a health check of all files involved, maybe even the whole dbf, your project and also foxuser.dbf resource files. Even the intelliisense  foxcode.dbf once caused a reproducible error. And now please, don't check your foxcode.dbf, just because I mentioned it last.

You examine such things with detective skills, switch components, even the whole computer, to see if anything on that client and driver or OS issue catches you.

Bye, Olaf.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.