错误C2504:'IDispatchImpl':基类未定义

时间:2016-12-08 22:01:26

标签: c++

我正在将项目从VS2008升级到VS2013。我遇到了以下错误(以及其他许多人,但这是第一个问题):

1>d:\express\ver38\ide\source\aimauto\AimConfiguration.h(12): error C2504: 'IDispatchImpl' : base class undefined
1>d:\express\ver38\ide\source\aimauto\AimConfiguration.h(12): error C2143: syntax error : missing ',' before '<'
1>d:\express\ver38\ide\source\aimauto\AimConfiguration.h(32): error C3646: 'COM_INTERFACE_ENTRY' : unknown override specifier
1>d:\express\ver38\ide\source\aimauto\AimConfiguration.h(32): error C2259: 'IDispatch' : cannot instantiate abstract class
1>          due to following members:
1>          'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract
1>          C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwnbase.h(114) : see declaration of 'IUnknown::QueryInterface'
1>          'ULONG IUnknown::AddRef(void)' : is abstract
1>          C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwnbase.h(118) : see declaration of 'IUnknown::AddRef'
1>          'ULONG IUnknown::Release(void)' : is abstract
1>          C:\Program Files (x86)\Windows Kits\8.1\Include\um\unknwnbase.h(120) : see declaration of 'IUnknown::Release'
1>          'HRESULT IDispatch::GetTypeInfoCount(UINT *)' : is abstract
1>          c:\program files (x86)\windows kits\8.1\include\um\oaidl.h(2187) : see declaration of 'IDispatch::GetTypeInfoCount'
1>          'HRESULT IDispatch::GetTypeInfo(UINT,LCID,ITypeInfo **)' : is abstract
1>          c:\program files (x86)\windows kits\8.1\include\um\oaidl.h(2190) : see declaration of 'IDispatch::GetTypeInfo'
1>          'HRESULT IDispatch::GetIDsOfNames(const IID &,LPOLESTR *,UINT,LCID,DISPID *)' : is abstract
1>          c:\program files (x86)\windows kits\8.1\include\um\oaidl.h(2195) : see declaration of 'IDispatch::GetIDsOfNames'
1>          'HRESULT IDispatch::Invoke(DISPID,const IID &,LCID,WORD,DISPPARAMS *,VARIANT *,EXCEPINFO *,UINT *)' : is abstract
1>          c:\program files (x86)\windows kits\8.1\include\um\oaidl.h(2202) : see declaration of 'IDispatch::Invoke'

头文件AimConfiguration.h中的代码是:

class aimConfiguration :
    public IDispatchImpl<IaimConfiguration, &IID_IaimConfiguration, &LIBID_aimAutomationLib,AIM_MAJOR_VER,AIM_MINOR_VER>,
    public ISupportErrorInfo,
    public CComObjectRoot,
    public CComCoClass<aimConfiguration,&CLSID_aimConfiguration>

atlcom.h在cpp文件中声明:

#include "stdafx.h"
#include "atlcom.h"
#include "aimAutomation.h"
#include "AimStrings.h"
#include "AimConfiguration.h"

我在搜索时发现了类似问题的引用,但我找不到任何解决方案。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

大多数ATL内容都在ATL名称空间中。我相信生成的stdafx.h定义了_ATL_NO_AUTOMATIC_NAMESPACE,因此您需要删除#define或使用using namespace ATL;(首选.cpp文件)或使用ATL::明确限定接口和内容(首选头文件) )。