AnsweredAssumed Answered

Error building MFC +ATL DLL for ArcObects

Question asked by erikadade on Dec 7, 2016

Hi,

 

I am upgrading a legacy ArcObjects projects to VS2013, ArcGIS10.3.1 and ArcObjectsSDKNet, while still on Win 7 Pro.  The project is a MFC DLL with ATL support, containing numerous MFC dialogs and one ATL COM class. The DLL is used by a VB.NET extension to provide custom tools for ArcMap. The extension communicates with the C++ DLL via the COM class. The model has been functioning since 2006, with upgrades along the way for ArcGIS and VS changes.

 

The MFC DLL will not build, with an error in the main.cpp:

error C2732: linkage specification contradicts earlier specification for 'DllGetClassObject'

The error references the declaration of the class in main:

// DllGetClassObject - Returns class factory
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    if (S_OK == _AtlModule.GetClassObject(rclsid, riid, ppv))
        return S_OK;
    return AfxDllGetClassObject(rclsid, riid, ppv);
}

 

I tried creating a new MFC DLL project with static link to MFC, which builds fine as is without adding anything after the solution wizard completes.  Then use class wizard to 'Add ATL support to MFC project' without changing anything else, and it fails with the same error.

 

Has anyone seen this kind of error and have any ideas what it is related too? Secondly, is there a better way to write a C++ DLL that a VB extension can call into?

 

Thank you for any help!

Outcomes