Hi,
Im new to programming and am attempting to implement an ATL COM server following a software development kit. However, I am having all sorts of problems. Iv created an ATL project and added a simple object called CoSensorServer. Iv then implemented interfaces:
IPMSensorServer,
IPMSensorConfig,
IPMPositionGenerator
and IPMSensorRuntime
from a library included in the SDK.
My CoSensorServer cpp file looks like this:
#include "stdafx.h"
#include "CoSensorServer.h"
class ATL_NO_VTABLE CCoSensorServer :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCoSensorServer, &CLSID_CoSensorServer>,
public ICoSensorServer,
public IPMPositionGenerator,
public IPMSensorConfig,
public IPMSensorRuntime,
public IPMSensorServer
{
public:
CCoSensorServer()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_COSENSORSERVER)
DECLARE_NOT_AGGREGATABLE(CCoSensorServer)
BEGIN_COM_MAP(CCoSensorServer)
COM_INTERFACE_ENTRY(ICoSensorServer)
COM_INTERFACE_ENTRY(IPMPositionGenerator)
COM_INTERFACE_ENTRY(IPMSensorConfig)
COM_INTERFACE_ENTRY(IPMSensorRuntime)
COM_INTERFACE_ENTRY(IPMSensorServer)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
public:
STDMETHOD(CreatePosGen)(GUID PosGenId, GUID SensorId, long * plType)
{
return E_NOTIMPL;
}
STDMETHOD(ConfigurePosGen)(GUID PosGenId, GUID SensorId, signed char * pbChanged)
{
return E_NOTIMPL;
}
STDMETHOD(RemovePosGen)(GUID PosGenId)
{
return E_NOTIMPL;
}
STDMETHOD(LoadPosGen)(GUID PosGenId, long lType, long lSize, unsigned char * pucBuffer, signed char * pbUpgraded)
{
return E_NOTIMPL;
}
STDMETHOD(SavePosGen)(GUID PosGenId, long * plSize, unsigned char * * ppucBuffer)
{
return E_NOTIMPL;
}
public:
STDMETHOD(InitServer)()
{
return E_NOTIMPL;
}
STDMETHOD(CreateSensor)(GUID SensorId)
{
return E_NOTIMPL;
}
STDMETHOD(ConfigureSensor)(GUID SensorId, signed char * pbChanged)
{
return E_NOTIMPL;
}
STDMETHOD(RemoveSensor)(GUID SensorId)
{
return E_NOTIMPL;
}
STDMETHOD(LoadSensor)(GUID SensorId, long lSize, unsigned char * pucBuffer, signed char * pbUpgraded)
{
return E_NOTIMPL;
}
STDMETHOD(SaveSensor)(GUID SensorId, long * plSize, unsigned char * * ppucBuffer)
{
return E_NOTIMPL;
}
STDMETHOD(ShowStatus)(GUID SensorId)
{
return E_NOTIMPL;
}
public:
STDMETHOD(StartSensor)(GUID SensorId, long lGenerators, GUID * pPosGenerators, _IPMSensorResult * p_IPMSensorResult)
{
return E_NOTIMPL;
}
STDMETHOD(StopSensor)(GUID SensorId)
{
return E_NOTIMPL;
}
STDMETHOD(ShowRuntimeInfo)(GUID SensorId, signed char bShow)
{
return E_NOTIMPL;
}
public:
STDMETHOD(GetName)(BSTR * bstrName)
{
return E_NOTIMPL;
}
STDMETHOD(GetDescription)(BSTR * bstrDescription)
{
return E_NOTIMPL;
}
STDMETHOD(GetVersion)(long * plMajor, long * plMinor)
{
return E_NOTIMPL;
}
};
OBJECT_ENTRY_AUTO(__uuidof(CoSensorServer), CCoSensorServer)
I am getting the following error when compiling:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1760): error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class<br />
with [ Base=CCoSensorServer ]<br />
<br />
<br />
<br />
<br />
The output:<br />
<br />
Rebuild All started: Project: MySensorServer, Configuration: Debug Win32 ------<br />
<br />
Deleting intermediate files and output files for project 'MySensorServer', configuration 'Debug|Win32'.<br />
Creating Type Library...<br />
Processing .\MySensorServer.idl<br />
MySensorServer.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\oaidl.idl<br />
oaidl.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\objidl.idl<br />
objidl.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\unknwn.idl<br />
unknwn.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\wtypes.idl<br />
wtypes.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\basetsd.h<br />
basetsd.h<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\guiddef.h<br />
guiddef.h<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\ocidl.idl<br />
ocidl.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\oleidl.idl<br />
oleidl.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\servprov.idl<br />
servprov.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\urlmon.idl<br />
urlmon.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\msxml.idl<br />
msxml.idl<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\oaidl.acf<br />
oaidl.acf<br />
Processing C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\ocidl.acf<br />
ocidl.acf<br />
Compiling...<br />
stdafx.cpp<br />
Compiling...<br />
CoSensorServer.cpp<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1760) : error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class<br />
with<br />
[<br />
Base=CCoSensorServer<br />
]<br />
due to following members:<br />
'HRESULT IPMPositionGenerator::ConfigurePosGen(GUID,GUID,char *)' : pure virtual function was not defined<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\externalsensor.tlh(102) : see declaration of 'IPMPositionGenerator::ConfigurePosGen'<br />
'HRESULT IPMPositionGenerator::LoadPosGen(GUID,long,long,unsigned char *,char *)' : pure virtual function was not defined<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\externalsensor.tlh(108) : see declaration of 'IPMPositionGenerator::LoadPosGen'<br />
'HRESULT IPMSensorConfig::ConfigureSensor(GUID,char *)' : pure virtual function was not defined<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\externalsensor.tlh(73) : see declaration of 'IPMSensorConfig::ConfigureSensor'<br />
'HRESULT IPMSensorConfig::LoadSensor(GUID,long,unsigned char *,char *)' : pure virtual function was not defined<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\externalsensor.tlh(78) : see declaration of 'IPMSensorConfig::LoadSensor'<br />
'HRESULT IPMSensorRuntime::ShowRuntimeInfo(GUID,char)' : pure virtual function was not defined<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\externalsensor.tlh(184) : see declaration of 'IPMSensorRuntime::ShowRuntimeInfo'<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1752) : while compiling class-template member function 'HRESULT ATL::CComCreator<T1>::CreateInstance(void *,const IID &,LPVOID * )'<br />
with<br />
[<br />
T1=ATL::CComObject<CCoSensorServer><br />
]<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1832) : see reference to class template instantiation 'ATL::CComCreator<T1>' being compiled<br />
with<br />
[<br />
T1=ATL::CComObject<CCoSensorServer><br />
]<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(1828) : while compiling class-template member function 'HRESULT ATL::CComCreator2<T1,T2>::CreateInstance(void *,const IID &,LPVOID * )'<br />
with<br />
[<br />
T1=ATL::CComCreator<ATL::CComObject<CCoSensorServer>>,<br />
T2=ATL::CComFailCreator<-2147221232><br />
]<br />
c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\CoSensorServer.cpp(135) : see reference to class template instantiation 'ATL::CComCreator2<T1,T2>' being compiled<br />
with<br />
[<br />
T1=ATL::CComCreator<ATL::CComObject<CCoSensorServer>>,<br />
T2=ATL::CComFailCreator<-2147221232><br />
]<br />
MySensorServer.cpp<br />
Generating Code...<br />
<br />
Build log was saved at "file://c:\Documents and Settings\Andre Bedon\My Documents\Visual Studio Projects\MySensorServer\Debug\BuildLog.htm"<br />
MySensorServer - 1 error(s), 0 warning(s)<br />
<br />
<br />
------ Skipped Rebuild All: Project: MySensorServerPS, Configuration: Debug Win32 ------<br />
<br />
Project configuration skipped because it is not selected in this solution configuration<br />
<br />
<br />
---------------------- Done ----------------------<br />
<br />
Rebuild All: 0 succeeded, 1 failed, 1 skipped<br />
Any ideas how I can overcome this error? Iv spent too many hours to no avail. Thanks very much in advance.
Andre