PRB: Can't Use Late Binding When Server Method Uses UDT (184898)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q184898 SYMPTOMS
When you have an ActiveX server that you created with Visual Basic version
6.0, you receive an error when accessing a method or property that accepts
and/or returns a user-defined type (UDT).
You receive one of the following errors when accessing a method that
returns a UDT or accepts a UDT as an argument:
Run-time Error '429':
ActiveX component can't create object
Compile error:
Only user-defined types defined in public object modules can be coerced
to or from a variant or passed to late-bound functions.
CAUSE
A method that returns or accepts a user-defined type (UDT) cannot be called
when using late binding.
Dim oMyObject as Object
Dim MyUDT as Object
Set oMyObject = CreateObject("MyProject.MyClass")
MyUDT = oMyObject.MyMethod '<-- This line generates a run-time error
' if MyMethod returns a UDT.
RESOLUTION
To correct this problem, you can use either of the following two solutions:
- Use early binding instead of late binding.
- Modify the server so that the method returns an object of another class
rather than a UDT.
STATUS
This behavior is by design.
REFERENCES
For information about binding ActiveX components in your project, refer to
the "Declaring an Object Variable" and "How Binding Affects ActiveX
Component Performance" topics in the Visual Basic product documentation.
For information about creating your own collection classes, refer to the
"Using Properties and Collections to Create Object Models" topic in the
Visual Basic product documentation.
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbnofix kbprb KB184898 |
---|
|