Re: Help! MID2039
Technically, a dual interface cannot derive from another
dual interface. This violates the dual interface contract -
that the functionality exposed through the vtable is equivalent
to the functionality exposed via the vtable methods above
IDispatch (and more precisely it violates the base interface's
dual contract, because the IDispacth impementation would
be richer than the vtable for the base dual interface).
In practice this has no adverse consequences and is therefore
an accepted (or at least tolerated) practice. You'll have to live
with the warning however.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"David Stuart" <nospam@example.com> wrote in message
news:pan.2007.03.09.22.58.07.973525@example.com...
Hi,
In one visual studio project I have an IDL which defines interfaces, for
example:
[
... usual stuff
]
library GenericTypesLib
{
[
object,
dual,
uuid(...),
helpstring("...")
]
interface IMyInterface : IDispatch
{
HRESULT AMethod();
}
}
Then, in another project in visual studio I have (something like) this:
[
...
]
library MyOtherLib
{
importlib("GenericTypes.tlb");
[
object,
dual,
uuid(...),
helpstring("...")
]
interface MyDerivedInterface : MyInterface
{
HRESULT AnotherMethod([in] MyInterface* test);
}
}
The MIDL compiler finds the first TLB just fine, but gives me a "MID2039"
error on the second interface, stating "interface does not conform to
[oleautomation] attribute".
If I change it to this:
interface MyDerivedInterface : IDispatch
{
HRESULT AnotherMethod([in] MyInterface* test);
}
Then the warning disappears.
NOTE!! The "MyInterface" class also works when it is in a parameter, as in
the above method.
I am deeply confused (and disturbed). Why can't I extend the previous
interface? Is this a restriction in COM? What am I not grokking??
--
David Stuart, FirstHand Technologies
Address: 300 - 350 Terry Fox Drive, Kanata Ontario, K2K 2P5