Using IDL
If you believe, as I do, that VB’s versioning scheme is more trouble than it is worth, a better way to gain complete control over GUIDs is to define your interfaces with the Interface Definition Language (IDL). Defining your interfaces in IDL has several advantages:
You eliminate the overhead of having a class for each interface in a VB project.
You have complete control over when GUIDs change and why.
If you use IDL and use
CreateObject
in your client code (for reasons that will be obvious shortly), then you can set the versioning setting in VB to anything you wish and it will not affect whether the clients work or not.
The only disadvantage in using IDL is that you have to learn how to use it, and for some reason VB developers shy away from it.
You learned about IDL in Chapter 4. IDL is not a full language in the sense that it does not allow you to write loops or have if...then...else statements and so on. IDL is a syntax language for defining interfaces. IDL enables you to build standalone type library files. Once you define your interface in IDL, you can compile it with MIDL, the Microsoft IDL compiler. MIDL can produce a variety of files, including header files for C++ clients, proxy-stub code for standard marshalers, and, most importantly for us, a standalone type library file. It would be impossible for me to show you every aspect of IDL in this section of the chapter, so I am going to show you the essentials for building a type library in IDL.
Reverse-Engineering Type ...
Get COM+ Programming with Visual Basic now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.