English

Error: A runtime error occurs when trying to add a variable or class to an ESRI 10.0 control using Visual Studio 2008 in an MFC form

Error Message

It is a common workflow for Visual C++ developers to generate wrapper classes for ActiveX controls, which makes it easier to access controls instead of working with the controls directly.

The steps to create these wrapper classes are as follows:

Create a new dialog-based MFC application in Visual Studio 2008. This brings up the designer view of the form. Now add an ActiveX Control by right-clicking on the form and selecting 'Insert ActiveX Control...' Select any control and click OK. Once the control has been added to the form, right-click the control and select 'Add Variable...' This brings up the 'Add Member Variable Wizard' that generates the wrapper classes.

When following this workflow with an ArcGIS Engine 10.0 control the following error occurs.

"A Runtime error has occurred.
Do you wish to Debug?

Line: 1211
Error: The Extender Provider failed to return an Extender for this object."

Cause

This is a bug with Visual Studio 2008; this problem has been reported to Microsoft. The problem is fixed in Visual Studio 2010.

Solution or Workaround

This issue occurs because the method Visual Studio 2008 uses to generate the wrappers cannot handle an ActiveX control with a library version higher than 9.0.

The following three options are possible workarounds to this issue:

▪ Generate the wrapper classes using a 9.3.1 control. Since the bug is specific to how the wrapper classes are generated, previously created wrappers will work correctly.

▪ Instead of using the wrapper classes, access the control directly. See the following code example:

Code:
CWnd* WndPageLayoutControl = GetDlgItem(IDC_PAGELAYOUTCONTROL3);

IPageLayoutControl3Ptr ipPageLayoutCntrl(WndPageLayoutControl->GetControlUnknown());

▪ This issue has been fixed in Visual Studio 2010; upgrade to Visual Studio 2010.