Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE Error 302 on .Add method
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
OLE Error 302 on .Add method
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01011419
Message ID:
01011419
Views:
97
I'm running into a strange problem that's got me stumped. I have a method in one class calling the .Add method of a collection and I'm getting the following error.

"OLE IDispatch exception code 302 from Visual FoxPro for Windows: Data type mismatch..."

The simplified code is as follows:
*-------------------------------------------------------
DEFINE Class1 AS Custom
*-------------------------------------------------------

   * Define properties etc.
   (Other properties omitted for demonstration purposes)
   
   ADD OBJECT PunchExceptions AS Collection

   * ---------------------------------------------------
   PROCEDURE IdentifyExceptions
   * ---------------------------------------------------
      LOCAL clsPunchException AS lppPunchException

      * Do various checks etc.
      ...

      IF (condition is true) THEN
         clsPunchException = CREATEOBJECT("lppPunchException")
         WITH clsPunchException
	    .Code = "CodeValue"
	    .Description = "DescriptionValue"
	    .Reason = "ReasonValue"
	    .Type = 0
	ENDWITH

        * <<< This is where the error occurs. >>>
	This.PunchExceptions.Add(clsPunchException)
      ENDIF

      * Cleanup code omitted.
                         
   ENDPROC
ENDDEFINE

*-------------------------------------------------------
DEFINE CLASS lppPunchException AS Custom
*-------------------------------------------------------

	#DEFINE mconZeroLengthString	""

	* Define properties and set default values
	* ----------------------------------------------
	Code		= mconZeroLengthString
	Description	= mconZeroLengthString
	Reason		= mconZeroLengthString
	Type		= 0

ENDDEFINE
The interesting thing here is that the error is generated every time the .Add method is called for the collection. However, even though the error is generated, the object is actually added to the collection. Given that, I COULD trap for it and ignore it, but I want to understand why it is happening in the first place. Also interesting is the fact that I have many other classes defined that do the same thing (i.e. creating an object and adding it to a collection) and this is the only place where the error is generated.

Neither class is defined as OLEPUBLIC or contains any properties/classes that could even contain an OLE or COM object. The error appears to be generated by Visual FoxPro itself within the .Add method - which is an existing method of a foundation class, but I don't know why. The only information I have found so far relates to redimensioning an array from within a COM object. I'm not using any arrays or COM objects here. It doesn't make any sense to me why this error is occurring or why it doesn't appear to keep the .Add method from completing. Am I missing something obvious?

Any ideas/suggestions would be appreciated.

Thanks,
John
John Groft
Consultant
Computer Task Group, Inc.
Next
Reply
Map
View

Click here to load this message in the networking platform