Solved

binary compatability

Posted on 2002-07-09
8
232 Views
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?

Cheers.
0
Comment
Question by:pigface
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 18

Expert Comment

by:mdougan
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.
0
 
LVL 22

Expert Comment

by:rspahitz
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...
0
 

Author Comment

by:pigface
ID: 7141169
The sub is in a class module within the DLL.
0
Independent Software Vendors: 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!

 
LVL 18

Accepted Solution

by:
mdougan earned 50 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:

http://www.microsoft.com/MSJ/0100/versioning/versioning.asp

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.

0
 
LVL 22

Expert Comment

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

Expert Comment

by:schworak
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.
0
 

Author Comment

by:pigface
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.

Thanks.
0
 
LVL 18

Expert Comment

by:mdougan
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

749 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