Microsoft KB Archive/195533

= INFO: Application Object Protected in Custom VFP COM Servers =

Article ID: 195533

Article Last Modified on 8/12/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q195533



SUMMARY
The application object in Microsoft Visual FoxPro version 6.0 custom COM servers is protected.



MORE INFORMATION
In Visual FoxPro 5.0, the application object was exposed by default in all custom COM servers. In Visual FoxPro 6.0, the application object is now "protected," so that it cannot be accessed outside a particular instance of the object.

To show this, build the following code into a Visual FoxPro COM .exe:

Sample Code
**********Server Code******************* DEFINE CLASS Test1 AS CUSTOM OLEPUBLIC

PROCEDURE retapp RETURN THIS.APPLICATION ENDPROC PROCEDURE retapp2 RETURN _VFP.APPLICATION ENDPROC ENDDEFINE **********End Server Code***************

**********Begin Client Code************ oX=CREATEOBJECT("SERVTEST.TEST1") oY=oX.retapp &&Works oZ=oX.retapp2 &&Works ?oY.Name ?oZ.Name ?oX.Application.Name &&Errors Occur *********End Client Code*************** The first two references work because they access the application object from within the instance of the object through a method and return the result to the client.

The last reference "oX.Application.Name" tries to reference the Application object directly from the client. This returns the following error message:

OLE error code 0x80020006: Unknown name

Keywords: kbinfo KB195533

-

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

© Microsoft Corporation. All rights reserved.