Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COM question

Status
Not open for further replies.

influent

Programmer
Jan 11, 2001
131
0
0
US
I'm new to COM and I have a few questions. Let's say you have an interface called Iface1 that is being accessed by app.exe, to get to a class called Class1. Now let's say that Iface1 has two methods, Run and Walk. Now say you want to add a method called Stop. If you add the Stop method to Class1 and it's interface to Iface1, will the interface stop working with app.exe without recompiling it, or even with a recompile? Or do you have to create a new interface (Iface2 and so on) for any added methods or properties? Can you include everything from Iface1 in Iface2, and phase out Iface1?
 
If you go to the properties section of project, and select "Component", you will see three options for version compatibility.

If you do not want to break your Interface, select Binary Compatibility and use the Browse button to select the version of the object that you want it compatible to.

This method will compare your new object with the old one. And if you have not:
1.) Removed
2.) Changed the Input Parameter Datatypes
3.) Changed the Return Parameter Datatypes
of any public procedure or method such as:
a.)Public Property
b.)Public Sub
c.)Public Function
then you have not broken the interface and you will not have to recompile any of the applications that rely on this object because the new object will have the same "Unique ID" as the old one.

This means that you can add:
1.) Private Procedures and Methods
2.) Public Procedures and Methods
3.) New Classes
to your object without having to recompile every application.
 
Okay, if I'm understanding you correctly, you're saying that as long as I use Binary Compatibility, and I haven't removed or made any changes to the original methods and whatnot, then I can whatever I want to the DLLs instead of creating new DLLs with a different name. Am I right? What happens if I need to rename a method or property in the interface/coclass?
 
If you add change or delete ANY public interface member or part of the member you risk breaking applications that have been early bound to it. Adding member functions to the end you can get the system to not generate new GUIDs but your not assured that the object will be backward compatible.

If you have Application A that has been bound to Interface A and you want to add another method and not have to recompile Application A then the appropriate thing to do is create a Interface B that Application B uses. Class1 would then impliment both the Interface A and B.

You also only have to distribute the new Proxy DLL to clients that need the Interface B.

Rule of thumb. NEVER change and interface after an application has been deployed for it. You expand functionality by adding new interfaces not by altering exsisting ones.

This said I alter interfaces all the time when I have control. I wear the work of recompiling, distributing and installing the updated App(s) and Object(s)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top