Microsoft KB Archive/894817

= BUG: A fatal exception error may occur and Visual FoxPro may close when you compile a class library by using a project build =

Article ID: 894817

Article Last Modified on 3/8/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 9.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-





SYMPTOMS
In Microsoft Visual FoxPro, a fatal exception error may occur and Visual FoxPro may close when you compile a class library by using a project build. This problem occurs when the class library contains a PROPERTIES field that does not end in a carriage return/line feed (CrLf) combination. This problem may randomly occur.



CAUSE
This problem occurs because the last character in the PROPERTIES field is not a line feed.

In Visual FoxPro, class libraries are Visual FoxPro tables that have the .vcx file name extension. These tables contain a field that is named PROPERTIES. This field contains the properties of the classes in the class library. The Visual FoxPro Class Designer terminates the contents of the PROPERTIES field by using a carriage return/line feed combination when you save the classes to the class library table. Third-party designers and third-party frameworks may terminate the contents of the PROPERTIES field by using only a carriage return. This may cause a fatal exception error to occur and Visual FoxPro to close when you compile the class library by using a project build.



RESOLUTION
To resolve this problem, examine the class library table before you compile it. Make sure that the PROPERTIES field is correctly terminated by using both a carriage return and a line feed. To do this, use code that is similar to the following code. CLOSE ALL CLEAR LOCAL lcVCXLib lcVCXLib = ; GETFILE('VCX', 'Open Library', 'OK', 0, 'Select Class Library') IF EMPTY(lcVCXLib) OR RIGHT(LOWER(lcVCXLib),3) <> 'vcx' RETURN ENDIF
 * 1) DEFINE CrLf CHR(13) + CHR(10)

LOCAL lnBadPropCnt, lcBadPropCriteria lnBadPropCnt = 0 lcBadPropCriteria = [LEN(properties) > 0 AND ] + ; [RIGHT(properties,1) <> CHR(10) AND ] + ; [UPPER(ALLTRIM(UNIQUEID)) <> 'RESERVED' AND ] + ; [!DELETED]

WAIT WINDOW 'Working....' NOWAIT NOCLEAR USE (lcVCXLib) IN 0 ALIAS TheClassLib SELECT TheClassLib COUNT FOR &lcBadPropCriteria TO lnBadPropCnt

IF lnBadPropCnt = 0 ? 'No bad PROPERTIES fields found.' ELSE PUBLIC goAlertForm goAlertForm = CREATEOBJECT('AlertForm') goAlertForm.CLASSLIB = lcVCXLib goAlertForm.lbl1.CAPTION = ; goAlertForm.lbl1.CAPTION + lcVCXLib SCAN IF &lcBadPropCriteria goAlertForm.edtclasses.VALUE = ; goAlertForm.edtclasses.VALUE + ALLTRIM(ObjName) + CrLf ENDIF ENDSCAN ENDIF

WAIT WINDOW 'Complete!' NOWAIT USE IN SELECT('TheClassLib') WAIT CLEAR goAlertForm.SHOW RETURN

DEFINE CLASS AlertForm AS FORM HEIGHT = 332 WIDTH = 375 AUTOCENTER = .T.   BORDERSTYLE = 1 CAPTION = &quot;Invalid PROPERTIES fields found&quot; MAXBUTTON = .F.   MINBUTTON = .F.    ALWAYSONTOP = .T.    CLASSLIB = '' NAME = &quot;Form1&quot;

ADD OBJECT lbl1 AS LABEL WITH ; WORDWRAP = .T., ; CAPTION = &quot;The following classes have an invalid &quot; + ; &quot;PROPERTIES field in class library &quot;, ; HEIGHT = 48, ; LEFT = 13, ; TOP = 10, ; WIDTH = 349, ; NAME = &quot;lbl1&quot;

ADD OBJECT lbl2 AS LABEL WITH ; WORDWRAP = .T., ; CAPTION = &quot;You should modify and then save each of these classes &quot; + ; &quot;in the Visual FoxPro Class Designer to repair the problem.&quot;, ; HEIGHT = 36, ; LEFT = 12, ; TOP = 252, ; WIDTH = 348, ; NAME = &quot;lbl2&quot;

ADD OBJECT cmdsave AS COMMANDBUTTON WITH ; TOP = 300, ; LEFT = 144, ; HEIGHT = 27, ; WIDTH = 120, ; CAPTION = &quot;Save list to file...&quot;, ; NAME = &quot;cmdSave&quot;

ADD OBJECT cmdclose AS COMMANDBUTTON WITH ; TOP = 300, ; LEFT = 276, ; HEIGHT = 27, ; WIDTH = 84, ; CANCEL = .T., ; CAPTION = &quot;Close&quot;, ; NAME = &quot;cmdClose&quot;

ADD OBJECT edtclasses AS EDITBOX WITH ; HEIGHT = 169, ; LEFT = 12, ; READONLY = .T., ; TOP = 72, ; WIDTH = 349, ; NAME = &quot;edtClasses&quot;

PROCEDURE cmdsave.CLICK LOCAL lcResultfile lcResultfile = ; PUTFILE('Save Report', 'Class_Scan.TXT', 'TXT') IF !EMPTY(lcResultfile) LOCAL lcOldSetSafety lcOldSetSafety = SET(&quot;Safety&quot;) SET SAFETY OFF STRTOFILE(              THISFORM.CLASSLIB + CrLf + CrLf + ;                THISFORM.edtclasses.VALUE + CrLf + CrLf, lcResultfile) SET SAFETY &lcOldSetSafety ENDIF ENDPROC

PROCEDURE cmdclose.CLICK THISFORM.RELEASE ENDPROC ENDDEFINE This code prompts you to select a class library table. Then the code examines the class library table for PROPERTIES fields where the last (terminating) character is not a line feed. If the code does not find any PROPERTIES fields where the last character is not a line feed, you receive a message that the code did not find any bad fields. Then the code closes the table. If the code does find PROPERTIES fields where the last character is not a line feed, you receive a report of the bad classes. You can save the report as a text file.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
To reliably reproduce the problem, you must have the Windows Application Verifier attached to Visual FoxPro. To do this, follow these steps:  Download and install the Microsoft Windows Application Compatibility Toolkit. For additional information, visit the following Microsoft Web site:

http://www.microsoft.com/windows/appcompatibility/toolkit.mspx

 Run the Windows Application Verifier, and attach it to Visual FoxPro. To do this, follow these steps:  In the Windows Application Verifier, click Add. In the Add Application dialog box, select the Visual FoxPro executable file for the version of Visual FoxPro that you are using. For example, you may select the VFP9.exe file. Then, click Open. In the Test settings area, click to select the PageHeap - Detect heap related errors (uses guard pages) check box.</li> In the Applications box, select the Visual FoxPro executable file, and then click Run.</li></ol> </li>  Paste the following code into a new program, and then run the code. CLOSE ALL ERASE xxTestClass.* loLine = NEWOBJECT('line') loLine.SAVEASCLASS('xxTestClass', 'xxTestClass')

USE xxTestClass.vcx REPLACE PROPERTIES WITH ; LEFT(PROPERTIES, LEN(PROPERTIES) - 2) + CHR(13) ; FOR RECNO = 2 USE
 * - This removes the typical CrLf added at the end
 * - of the properties field and replaces it with just a Cr

BUILD PROJECT xxTestClass FROM xxTestClass.vcx Note This code creates a class library table that contains PROPERTIES fields that end in only a carriage return. Then the code builds a project that contains the class library. A fatal exception error occurs, and Visual FoxPro closes. </li></ol>

Keywords: kbbug KB894817

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.