Data Access Worldwide Knowledge Base

Article ID 2226
Article Title INFO: Usage of a COM solution where I cannot match the VB sample code with VDF code
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2226
KBase Category VDF11
Date Created 06/22/2006
Last Edit Date 07/19/2006


Article Text
PROBLEM:
We have a FoxPro application that has a COM interface so we thought we could use the functionality to import the automation library with Visual DataFlex. We imported the library but, to write the Visual DataFlex code, we looked at the Visual Basic examples supplied by the manufacturer and I noticed a mismatch. Only one wrapper class was created and some methods called in the Visual Basic example code show use of parameters while the generated class does not expose this. Is this a bug?

ANSWER:
No, it is not a bug. When we opened this application with Microsoft's OLEViewer we saw what interfaces were exposed via the typelib. The Visual DataFlex COM class generator does the same as OleViewer does and enumerates the interfaces of the typelib and writes the DataFlex wrapper classes.

The Visual Basic sample code used classes and other method interfaces than the generated ones. These interfaces were not marked as hidden in the typelib so not skipped because of that.

Visual Basic programmers need to know - must be exposed in documentation - the class and their method names plus the exact number (and type) of parameters to use interfaces that are not exposed via the typelib interface. Visual Basic supports some sort of built-in query at runtime to enumerate live objects via a ITypeInfo and related interfaces.

To use this built-in mechanism programmers need to be very careful when writing code because making a small mistake in the method/class names and/or the right number (type) of the method arguments will produce runtime errors.

CONCLUSION:
You cannot use this COM interface from Visual DataFlex but even using C++ to build your application would make the access very tedious and adds a significant overhead.


Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.