BUG: A fatal exception error may occur and Visual FoxPro may close when you compile a class library by using a project build (894817)
The information in this article applies to:
- Microsoft Visual FoxPro 9.0 Professional Edition
- Microsoft Visual FoxPro 8.0
- Microsoft Visual FoxPro for Windows 7.0
- Microsoft Visual FoxPro for Windows 6.0
SYMPTOMSIn 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.CAUSEThis 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.RESOLUTIONTo 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. #DEFINE CrLf CHR(13) + CHR(10)
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
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 = "Invalid PROPERTIES fields found"
MAXBUTTON = .F.
MINBUTTON = .F.
ALWAYSONTOP = .T.
CLASSLIB = ''
NAME = "Form1"
ADD OBJECT lbl1 AS LABEL WITH ;
WORDWRAP = .T., ;
CAPTION = "The following classes have an invalid " + ;
"PROPERTIES field in class library ", ;
HEIGHT = 48, ;
LEFT = 13, ;
TOP = 10, ;
WIDTH = 349, ;
NAME = "lbl1"
ADD OBJECT lbl2 AS LABEL WITH ;
WORDWRAP = .T., ;
CAPTION = "You should modify and then save each of these classes " + ;
"in the Visual FoxPro Class Designer to repair the problem.", ;
HEIGHT = 36, ;
LEFT = 12, ;
TOP = 252, ;
WIDTH = 348, ;
NAME = "lbl2"
ADD OBJECT cmdsave AS COMMANDBUTTON WITH ;
TOP = 300, ;
LEFT = 144, ;
HEIGHT = 27, ;
WIDTH = 120, ;
CAPTION = "Save list to file...", ;
NAME = "cmdSave"
ADD OBJECT cmdclose AS COMMANDBUTTON WITH ;
TOP = 300, ;
LEFT = 276, ;
HEIGHT = 27, ;
WIDTH = 84, ;
CANCEL = .T., ;
CAPTION = "Close", ;
NAME = "cmdClose"
ADD OBJECT edtclasses AS EDITBOX WITH ;
HEIGHT = 169, ;
LEFT = 12, ;
READONLY = .T., ;
TOP = 72, ;
WIDTH = 349, ;
NAME = "edtClasses"
PROCEDURE cmdsave.CLICK
LOCAL lcResultfile
lcResultfile = ;
PUTFILE('Save Report', 'Class_Scan.TXT', 'TXT')
IF !EMPTY(lcResultfile)
LOCAL lcOldSetSafety
lcOldSetSafety = SET("Safety")
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 "Applies to" section.
Modification Type: | Major | Last Reviewed: | 3/8/2005 |
---|
Keywords: | kbbug KB894817 kbAudDeveloper |
---|
|