Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ COM
Hello, I have a question. I have a dll COM with version A and I have a new version of this dll (version B). Version B supports backward compatibility i.e: When I compile application with the version A of dll it works fine. When we launch it on machine that has version B installed.
 
I suppose my description is clear Frown | :(
 
Now what do I need if the inverse is true or not?
i.e : If I compile my application with the new version of dll(version B) and launch my application on machine which have the version A installed. Will this work or not?
Posted 17-Apr-13 6:51am
Edited 17-Apr-13 6:55am
v2
Comments
ThePhantomUpvoter at 17-Apr-13 12:12pm
   
"I suppose my description is clear", no it really is not clear at all.
 
"When we launch it on machine that has version B installed", is not a complete sentence.
 
"Will this work or not? ", that depends. You can only call functions in your COM object that is supported by the version installed on the target machine.
khaliloenit at 17-Apr-13 12:31pm
   
sorry for that
Normally the backward compatibility was planed to ensure that if one soft is compiled for an old version of the library, it can continue to work with the new higher version of the library without recompilation or special adaptation.(situation 1)
 
is the reverse also true?
 
means if the soft is compiled with the new higher version of dll it can continue to work with the old version of the library without recompilation or special adaptation.(situation 2)
 
My situation is the first one, So I ask if should I have also situation 2 works ?
ThePhantomUpvoter at 17-Apr-13 13:37pm
   
No. I think you misunderstand how COM works. You do not compile your code to include a specific version of a COM component. Your code would instantiate the COM component and use it. If the DLL does not support the functions you are calling then it's going to fail. You situation 2 is called "backwards compatibility". You cannot call functions in a DLL that your code does not know anything about.
khaliloenit at 17-Apr-13 12:27pm
   
sorry for that
Normally the backward compatibility was planed to ensure that if one soft is compiled for an old version of the library, it can continue to work with the new higher version of the library without recompilation or special adaptation.(situation 1)
is the reverse also true?
means if the soft is compiled with the new higher version of dll it can continue to work with the old version of the library without recompilation or special adaptation.(situation 2)
my situation is the first one, So I ask if should I have also situation 2 works ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

COM has strict rules: Interfaces must be immutable. You must never, ever change the interface in a new version of a COM DLL. You may add interfaces, however.
Now, supposing you have (strictly) followed the COM rules, the new DLL, supports the old interface and possibly new ones. IF object B relies on one of the new interfaces, then the corrensponding QueryInterface would fail when called on the old COM DLL.
  Permalink  
Comments
LaxmikantYadav at 18-Apr-13 8:20am
   
My +5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In general case, not. Actually, that's why, in addition to compatibility, COM components should support versioning.
 
Now, why? To understand it, you should consider layout of memory pointed by interface pointer and two side: a component and using code. Here is the illustration. From C++ perspective, consider it as pseudo-code:
//Old component:
interface A {
   MethodOne();
}
 
//New component:
interface A {
   MethodOne();
   MethodTwo();
}
 
//Old using code:
A a = //...
a.MethodOne(); // valid for both new and old versions of A

//New using code:
A a = //...
a.MethodOne(); // valid for both new and old versions of A
// and, in general case:
a.MethodTwo(); // valid for new version of A, will try to call non-existent method of old version of A
 
Are you getting the idea?
 
—SA
  Permalink  
v2
Comments
khaliloenit at 18-Apr-13 5:04am
   
So conclusion, it is impossible to ensure this ?
And caller should have at least the new version of COM to works ?
Sergey Alexandrovich Kryukov at 18-Apr-13 10:16am
   
Impossible to ensure without additional functionality like version information.
 
The simple approach: you can have some interface with some version and version comparison. And this interface should be only one, never changed.

If the using code of newer version uses older or the same version of interface, it's fine.
Otherwise, the using code throws exception and says something like "you are using obsolete version of the application; please upgrade..." and provide the access to upgraded version, download or something like that.
 
How to compare and modify versions during development? Introduce some policy. When you support versions, you can consider, for example, that too or one most significant numbers of the version mean incompatibility (say, ignore release/build components of the versions in comparison). It means that only implementation detail is changed. (Or support separate versioning for interfaces and implementations and compare separately. This can be over-complicated. It depends on your development branches.)
 
Never delete members of any exposed interfaces in the evolution. If you really need to phase out some of them, develop some deprecation mechanism, so the deprecated members are always available, but using them provides some warning.
 
Are you getting the idea?
 
—SA
khaliloenit at 22-Apr-13 4:51am
   
yes.thank you
Sergey Alexandrovich Kryukov at 22-Apr-13 11:13am
   
You are welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 504
1 Maciej Los 349
2 Kornfeld Eliyahu Peter 325
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100