Cannot instantiate abstract class due to following members

Hi,
I am extreme newb in COMs, need help compiling a program.
I am using VS2010
Following is the error
1>------ Build started: Project: CppComSample, Configuration: Debug Win32 ------
1>Build started 6/22/2010 3:52:33 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\CppComSample.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  CppComSample.cpp
1>c:\dev\anyconnect_api_2\examples\cppcomsample\cppcomsample.cpp(60): error C2259: 'CCppComSampleDlg' : cannot instantiate abstract class
1>          due to following members:
1>          'HRESULT IVpnApiEvents::raw_VpnBannerNotification(BSTR)' : is abstract
1>          c:\dev\anyconnect_api_2\examples\cppcomsample\debug\vpnapi.tlh(491) : see declaration of 'IVpnApiEvents::raw_VpnBannerNotification'
1>
1>Build FAILED.
1>


Here are the relevant files
CppComSample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/********************************************************************************\
*  This sample is supplied as is with no implied warranty.  
*  It is designed to assist you in using the Cisco AnyConnect VPN API. 
*  It is assumed that you will build a production application and 
*  refer to this sample as a reference only.
\********************************************************************************/
#include "stdafx.h"
#include "CppComSample.h"
#include "CppComSampleDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

BEGIN_MESSAGE_MAP(CCppComSampleApp, CWinApp)
    ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()

//You need a global CComModule to use ATL COM coclass like CEventCallBack.
//NOTE: CComModule is used so that this example can be potentially backported to VC6.
//      You can convert this to ATL 7.x or later COM if you want to.
CComModule _Module;

CCppComSampleApp::CCppComSampleApp()
{
}


// The one and only CCppComSampleApp object
CCppComSampleApp theApp;


BOOL CCppComSampleApp::InitInstance()
{
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    InitCtrls.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES;
    ::InitCommonControlsEx(&InitCtrls);

    CWinApp::InitInstance();

    //Initialization of COM.  In this sample, COM is intentionally initialized
    //in STA mode so that the developer does not have to worry about threading and
    //serialization.  See ReadMe_First.htm for more details on this topic.
    //
    HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED 
                                            | COINIT_DISABLE_OLE1DDE
                                            | COINIT_SPEED_OVER_MEMORY);
    if (FAILED(hr))
    {
        ::MessageBox(::GetDesktopWindow(), _T("Unable to initialize COM"), 
                     _T("ERROR"), MB_OK | MB_ICONERROR);
        return FALSE;
    }
    else
    {
        AfxEnableControlContainer();
        SetRegistryKey(_T("AnyConnect VPN API Sample COM Application"));

        CCppComSampleDlg dlg;
        m_pMainWnd = &dlg;

        INT_PTR nResponse = dlg.DoModal();
        if (nResponse == IDOK)
        {
        }
        else if (nResponse == IDCANCEL)
        {
        }

    } // This scopes all COM smart pointers to ensure they are released.

    //All smart pointers must be cleaned up before COM is uninitialized or a crash will occur.
    ::CoUninitialize();

    return FALSE;
}


vpnapi.tlh snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
struct __declspec(uuid("5d446dc1-a494-4d3d-b5ad-0adacb3b3ee3"))
IVpnApiEvents : IDispatch
{
    //
    // Wrapper methods for error-handling
    //

    HRESULT VpnStatsNotification (
        struct IVpnStats * pVpnStats );
    HRESULT VpnStateNotification (
        enum VPNState eState,
        _bstr_t strState );
    HRESULT VpnBannerNotification (
        _bstr_t strBannerMessage );
    HRESULT VpnNoticeNotification (
        _bstr_t strNoticeMessage,
        enum MessageType eMessageType );
    HRESULT VpnExitNotification (
        _bstr_t strExitMessage,
        long exitCode );
    HRESULT VpnServiceReadyNotification ( );
    HRESULT VpnUserPromptNotification (
        struct IConnectPromptInfo * pConnectPromptInfo );
    HRESULT VpnWMHintNotification (
        enum WMHint eHint,
        enum WMHintReason eReason );
    HRESULT VpnWebLaunchHostNotification (
        _bstr_t strActiveHost );
    HRESULT VpnEventAvailableNotification ( );

    //
    // Raw methods provided by interface
    //

      virtual HRESULT __stdcall raw_VpnStatsNotification (
        /*[in]*/ struct IVpnStats * pVpnStats ) = 0;
      virtual HRESULT __stdcall raw_VpnStateNotification (
        /*[in]*/ enum VPNState eState,
        /*[in]*/ BSTR strState ) = 0;
      virtual HRESULT __stdcall raw_VpnBannerNotification (
        /*[in]*/ BSTR strBannerMessage ) = 0;
      virtual HRESULT __stdcall raw_VpnNoticeNotification (
        /*[in]*/ BSTR strNoticeMessage,
        /*[in]*/ enum MessageType eMessageType ) = 0;
      virtual HRESULT __stdcall raw_VpnExitNotification (
        /*[in]*/ BSTR strExitMessage,
        /*[in]*/ long exitCode ) = 0;
      virtual HRESULT __stdcall raw_VpnServiceReadyNotification ( ) = 0;
      virtual HRESULT __stdcall raw_VpnUserPromptNotification (
        /*[in]*/ struct IConnectPromptInfo * pConnectPromptInfo ) = 0;
      virtual HRESULT __stdcall raw_VpnWMHintNotification (
        /*[in]*/ enum WMHint eHint,
        /*[in]*/ enum WMHintReason eReason ) = 0;
      virtual HRESULT __stdcall raw_VpnWebLaunchHostNotification (
        /*[in]*/ BSTR strActiveHost ) = 0;
      virtual HRESULT __stdcall raw_VpnEventAvailableNotification ( ) = 0;
};


Any help will be deeply appreciated...
Last edited on
My educated guess: On line 60, a "CCppComSampleDlg" object is created, and it inherits from IVpnApiEvents, which has some pure virtual functions. The CCppComSampleDlg class does not redefine some of the pure virtual methods, so it can't be initialized as some of the functions aren't defined.
Or if "CCppComSampleDlg" does not inherit IVpnApiEvents, it contains either an object of IVpnApiEvents, or an object which inherits IVpnApiEvents but does not override the virtual functions.
So the same error will happen.
Last edited on
Topic archived. No new replies allowed.