Visual Basic Concepts
Classes can have properties and methods of any public data type supported by Automation. This includes all arguments of properties and methods, as well their return values. The allowed data types include:
The following data types are not allowed, and references to them should never be returned to client applications:
Visual Basic prevents you from passing non-visual private objects to or from out-of-process components. Attempting to do so causes error 98, "A property or method call cannot include a reference to a private object, either as an argument or as a return value." This error is always received by the client.
In other cases, it is possible to trick Visual Basic and pass private objects to client programs. Don’t do this. References to private objects will not keep a component running.
If your component shuts down, because all references to your public objects have been released, any remaining private objects will be destroyed, even if clients still hold references to them.
Subsequent calls to the properties and methods of these objects will cause errors, in the case of out-of-process components. In the case of in-process components, a fatal program fault may occur in the client.
Important Private objects are private for a reason, usually because they were not designed to be used outside your project. Passing them to a client may decrease program stability and cause incompatibility with future versions of Visual Basic. If you need to pass a private class of your own to a client, set the Instancing property to a value other than Private.
For More Information "Building Code Components" shows how events can eliminate the need for public call-back classes, allowing Standard EXE projects to use call-backs without providing public objects or passing out references to private objects.