Microsoft KB Archive/306079

= PRB: SET PROCEDURE TO causes unknown error with FoxPro DLL =

Article ID: 306079

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q306079



SYMPTOMS
If a COM dynamic-link library (DLL) which uses SET PROCEDURE TO is instantiated more than once, the Init method of the second instance may fail with one of the following messages:

OLE error code 0x80004005: Unspecified error.

OLE error code 0x80020009: Exception occurred.



CAUSE
To instantiate an OLEPUBLIC class, Visual FoxPro must be able to find all the code for the class. There is an internal SET PROCEDURE/SET CLASSLIB to detect all the related code; if you try to change this setting, an error occurs.



RESOLUTION
Use SET PROCEDURE TO with the ADDITIVE keyword.



STATUS
This is by design.



Steps to Reproduce Behavior
To see this behavior, run the following code. Uncomment the ADDITIVE clause for the code to work. CLOSE ALL SET SAFETY OFF ERASE testLib.* ERASE comTest.*

SET TEXTMERGE TO testLib.prg NOSHOW TEXT *!* Dummy function library ENDTEXT

SET TEXTMERGE TO comTest.prg NOSHOW TEXT DEFINE CLASS comTest AS Custom OLEPUBLIC FUNCTION SetProc SET PROCEDURE TO testlib &&ADDITIVE ENDFUNC ENDDEFINE ENDTEXT

BUILD PROJECT comtest FROM comtest.prg BUILD DLL comtest FROM comtest

loComTest1 = CREATEOBJECT(&quot;ComTest.ComTest&quot;) loComTest1.SetProc loComTest2 = CREATEOBJECT(&quot;ComTest.ComTest&quot;) && This line will give error.

Keywords: kbcodesnippet kbpending kbprb KB306079

-

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

© Microsoft Corporation. All rights reserved.