Solved

binary compatability

Posted on 2002-07-09
8
233 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
[X]
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
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

717 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