Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


binary compatability

Posted on 2002-07-09
Medium Priority
Last Modified: 2010-05-02
If I change a sub from a private to a public in a dll, will this screw up binary compatability?

Question by:pigface
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
LVL 18

Expert Comment

ID: 7141152
When you say DLL, I'm assuming that you mean a Sub within a Class within an Active-X DLL?  If so, the answer is yes.

If you change a Sub that is not part of a class (say in a bas module), then it shouldn't affect binary compatibility, but if you change a sub that is part of a class, then this will change that class's Interface.  And this is what breaks the compatibility.

Other things that will cause a break in compatibility include changing the number or type of parameters to a public class method, changing Enums defined in a Class module.
LVL 22

Expert Comment

ID: 7141154
Listening...but I don't think so.  The problem would be the other way around: change public to private.

I think the binary compatibility has to do with the interface.  As long as you don't delete or change and interface, you maintain compatability.  Adding has no effect.

Since changing from private to public should be considered an "Add" I would expect this to work.

Do you already have the dll?  It should be easy enough to try...

Author Comment

ID: 7141169
The sub is in a class module within the DLL.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 18

Accepted Solution

mdougan earned 200 total points
ID: 7141713
It's a little more complicated than we've been saying.

It's true that Adding to the public interface (so, changing a private to a public or adding a new public method) will probably not trigger VB to generate the warning message about breaking compatibility.  But I think what happens behind the scenes is that ANY change to the Interface (adds, deletes, or changes) causes a new IID (interface id) to be generated, and then the old Interface method pointers are actually forwarded to point to the new Interface vtable entries.  

The thought behind this is that by allowing calls to the old interface to be forwarded along to the same methods in the new interface, you keep from having to recompile the old applications.

Here is a pretty complete description of what is going on behind the scenes:


Now, during development, you are continually adding new methods to your components, which creates larger and large chains of forwarded interfaces in the registry.  Eventually, some registry entry will get hosed and the chain will break down.

They say that after doing the bulk of your development, go ahead and intentionally break your compatibility, so that you get all new GUIDS, have no more IID forwarding.  Then, distribute your component.  If you have it referenced in any VB program (under the Project|References menu) and are using Early binding (Dim x as New MyClass), then you will likely have to open the project, fix the reference and recompile.

If you use late binding in your applications (dim x as object    set x = CreateObject("MyDLL.MyClass"))  then you probably won't have to fix any references, and as long as you haven't deleted or changed any methods that the client was using, it should still run fine without recompiling.

LVL 22

Expert Comment

ID: 7141767
Very good description md.  I think you're probably right about the new ID and chain of links.

Expert Comment

ID: 7142102
No, binary compatibility will be retained. The problem is the COM interface will be changed and that will cause incompatibility issues.

I personally think this to be a bug in the binary compatibility check that VB does because by changing the interface you are making the control incompatibile with older exe's that may be using it.

Sorry, I just went through this a few month back and it totally made me crazy.

Author Comment

ID: 7142734
Firstly thanks to all of you for excellent suggestions.  Normally when peole post comments you normally get one or two duff ones.  But I have to say you guys know your stuff.

mdougan, special thanks for your excellent information.

LVL 18

Expert Comment

ID: 7143129
like schworak, I've had to go through this stuff until it makes you crazy.  If I can help one person get through it faster, I'm happy!  The link posted above is one of the best I've seen on the topic, I've saved a copy for later reference.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question