Attributed COM/ATL: implements() attribute not working with dual interface

T

Todd Brooks

I have a coclass that implements a dual interface. The thing that's a little
unusual is that the coclass doesn't inherit directly from the interface,
rather it inherits from an implementation class that inherits from the
interface. This means that by default the attribute code generator doesn't
pick up the interface. According to the docs, I should be able to use the
implements() attribute to tell the compiler that the coclass implements that
particular interface. Unfortunately, that doesn't seem to be working as I
get the following compiler errors, basically telling me that there's no
implementation of the IDispatch interface:
c:\Dev\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1759):
error C2259: 'ATL::CComObject<AssetMonitor>': cannot

instantiate abstract class; due to following members:; 'HRESULT
IDispatch::GetTypeInfoCount(UINT *)': pure virtual function was not

defined; c:\Dev\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\OAIdl.h(2712) : see declaration of 'IDispatch::

GetTypeInfoCount'

<etc.>

I also tried using

com_interface_entry ("COM_INTERFACE_ENTRY(IAssetMonitor)")

To force the interface, which has worked in the past for VTABLE-only
interfaces. But it's still not giving me the IDispatch implementation. I
even tried to be clever and directly inherit from IDispatchImpl, like so:

class ATL_NO_VTABLE AssetMonitor : public AssetComObject<IAssetMonitor>,
public
IDispatchImpl<AssetMonitor>
{
};

But it told me that base class AssetMonitor was undefined? (BTW,
AssetComObject<> is the implementation class that inherits from the
interface I want to implement).

So is there any way to do this? Like I said, I've done similar things with
vtable interfaces in the past, but for some reason it's just not working
with a dual interface. Any help would be appreciated. The attribute blocks
for both the interface and the coclass are included below:

[
object,
dual,
uuid("18F9BF13-9AE5-48AC-8D9A-C3D5A3B71157"),
helpstring("IAssetMonitor Interface"),
pointer_default(unique)
]
__interface IAssetMonitor : IDispatch
{
};



[
coclass,
threading("both"),
vi_progid("TruAssets.AssetMonitor"),
progid("TruAssets.AssetMonitor.1"),
version(1.0),
uuid("2C299443-FA0A-4B5E-ACF9-74526E875460"),
helpstring("TruAssets Asset Monitor Object"),
implements(IAssetMonitor),
implements(IObjectControl),
implements(IObjectConstruct),
default(IAssetMonitor),
support_error_info("IAssetMonitor")
]
class ATL_NO_VTABLE AssetMonitor : public AssetComObject<IAssetMonitor>
{
};
 
T

Tian Min Huang

Hi,

Thanks for your posting. I am checking this issue and will update you with
my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
T

Tian Min Huang

Hello Todd,

I am very glad to hear that you have resolved the problem. Based on my
experience and research, yours is the right method, please refer to MSDN
documentatio on IDispatchImpl:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/
_atl_IDispatchImpl.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top