FIX: Creating A Class with the Same Name as a Base Class Causes Error (299799)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q299799

SYMPTOMS

If you create a class by using the DEFINE CLASS command that has the same name as one of the Visual FoxPro (VFP) base classes, you receive the following error message when the class is instantiated:
OLE error code 0x80020006: Unknown name.

CAUSE

Custom classes cannot have the same name as base classes. If you try to compile the project into a dynamic-link library (DLL), you receive the following error message:
Class name is invalid.

STATUS

This problem was corrected in Visual FoxPro version 7.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

Save the following code as a program, and then run the program:
*!* Q299799 FIX: Creating A Class With The Same Name As A Base Class Causes Error
LOCAL lcVar
CREATE PROJECT oleclasstest NOWAIT

lcVar = "DEFINE CLASS Column AS CUSTOM OLEPUBLIC" + CHR(13) + CHR(10) + ;
             "   Test = ''" + CHR(13) + CHR(10) + "ENDDEFINE"

=STRTOFILE(lcVar, 'Test.prg', .F.)
_VFP.ACTIVEPROJECT.FILES.ADD('Test.prg')
_VFP.ACTIVEPROJECT.BUILD('test.dll', 4)
oObject = CREATEOBJECT('test.Column')
CLEAR
? oObject.Test
? oObject.BASECLASS
				

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbCodeSnippet kbOOP kbvfp700fix KB299799