Microsoft KB Archive/199848

= BUG: Fatal Error When Releasing a Converted FoxPro 2.x Form =

Article ID: 199848

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q199848



SYMPTOMS
Visual FoxPro terminates when you release a converted FoxPro 2.x form. Depending on the version of Visual FoxPro, one of the following error messages appear:

Visual FoxPro 6.0 displays the following message:

   Fatal Error: Exception Code=C0000005

Visual FoxPro 3.x and Visual FoxPro 5.x, display a message box captioned "VFP.EXE APPLICATION ERROR" that contains a message similar to the following:

  The instruction at "0x0046ae8e" referenced memory at "0x00000020". The memory count not be "read".

-or-

Visual FoxPro 3.0 and Visual FoxPro 5.0x produce this error:

VFP caused an invalid page fault in module VFP.EXE at 0137:0045e07a.

-or-

Visual FoxPro hangs and does not close. The Visual FoxPro session or the executable created with Visual FoxPro then terminates.



CAUSE
This behavior may occur in forms that have been functionally converted from screens created using FoxPro 2.x and an attempt is made to release the converted formset from memory while an @ ... GET statement is active.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
With earlier versions of FoxPro, there are some conditions in which a developer may have found it desirable to include @ ... GET statements in the ERROR, MESSAGE, VALID, or WHEN clause of certain controls.

When screens created with FoxPro 2.x are functionally converted to Visual FoxPro forms, @ ... GET statements, used to generate a FoxPro 2.x screen, are converted to a corresponding Visual FoxPro control. Likewise, any code contained in any of the clauses of the control is copied to a corresponding Visual FoxPro form method. If the ERROR, MESSAGE, VALID, or WHEN clause of a FoxPro 2.x screen contains an @ ... GET statement, then the @ ... GET statement is copied into the Visual FoxPro as code and is not treated as a form control.

Steps to Reproduce Behavior
 Using FoxPro 2.6 create a quick screen named ztest.  Add the following code to the screen SETUP:

     STORE "This is a test" to test_var

 Add a Get field to the screen.  In the Valid Clause of the Get field, add the following code:

<pre class="fixed_text">     @ 1, 15 GET test_var </li> Add a push button to the screen. Set the variable to "test", and then set it to Terminate Read.</li> Save the form.</li> From Visual FoxPro, modify the form and select functional conversion.</li>  In the Command window type:

<pre class="fixed_text">     DO ZTEST.SPR </li> Click the command button.</li></ol>

The following Visual FoxPro code illustrates the error that occurs.

NOTE: The memory error may not occur under Visual FoxPro 3.0x when running the .spr file created in the conversion process. However, Visual FoxPro 5.0x and 6.0 do produce the problem.

WARNING: To minimize the risk of corruption associated with abnormal program termination, it is recommended that any open databases and tables be closed before running the following code.

<ol>  Create a program called "Showtest.prg" using the following code:

*!* Begin Code DO TEST RELEASE ox

PROCEDURE TEST PUBLIC ox  ox=CREATEOBJECT('testset') ox.SHOW

DEFINE CLASS testset AS FORMSET AUTORELEASE =.t.        WINDOWTYPE  = 2

ADD OBJECT form1 AS test1 WITH ; TOP   = 0, ; LEFT  = 0, ; HEIGHT = 250, ; WIDTH = 375 ENDDEFINE

DEFINE CLASS test1 AS FORM DOCREATE = .T.     CAPTION  = "Form1" NAME    = "Form1"

PROCEDURE activate m.cust_id="this is a test" @ 10,1 GET m.cust_id ; SIZE 1, 25 ENDPROC

ADD OBJECT command1 AS COMMANDBUTTON WITH ; TOP = 192, ; LEFT = 48, ; HEIGHT = 25, ; WIDTH = 241, ; CAPTION = "E\<xit", ; TERMINATEREAD=.t., ; NAME = "Command1"

PROCEDURE command1.CLICK RELEASE THISFORM ENDPROC ENDDEFINE *!* End Code </li>  At the command prompt type:

<pre class="fixed_text">     DO SHOWTEST </li> Click the command button labeled "Exit"</li>  Depending on the version of Visual FoxPro, one of the following occurs:

Visual FoxPro 6.0 displays the following message:

<pre class="fixed_text">     Fatal Error: Exception Code=C0000005

Visual FoxPro 3.x and Visual FoxPro 5.x, display a message box captioned "VFP.EXE APPLICATION ERROR" that has a message similar to the following:

<pre class="fixed_text">    The instruction at referenced memory at.

The memory count not be "read".

-or-

Visual FoxPro 3.0 and Visual FoxPro 5.0x produce this error:

<pre class="fixed_text">     VFP caused an invalid page fault in  module VFP.EXE at.

-or-

Visual FoxPro hangs and does not close. </li></ol>

<div class="references_section">