wxWidgets 3.0.4, in the form of a pre-built VS 2010 64-bit DLL, debug build.
Windows 7 Pro, VS 2017.
This is my first time developing in CLR, so I may be making a rookie mistake.
The DLL is one we use successfully in other projects, but as far as I know this is the first usage within a CLR host application.
The main VS 2017 C#/CLR DLL project implements a plugin to the CLR host application. It calls into:
A new VS210 C++/CLI DLL project, implementing a CLR interface, a middle man which calls into:
A legacy VS2010 C++ DLL project, a collection of legacy wxWidgets dialogs, which calls into:
The pre-built wxWidgets DLL mentioned above.
I've already successfully displayed the first simple wxWidgets dialog in the collection. I've run into a road block with the second, much more complex dialog. The interface to this dialog is implemented as a series of functions. Static variables are used to store wx application and dialog state information. There is a creation function, a display function, a destruction function, and a bunch of getter and setter functions for interacting with the dialog state. My problem is in the creation function, ConfigCreate(), which emits the errors below in the Output window. (Uiwrapper.dll is the C++/CLI project.)
Exception thrown: 'System.AccessViolationException' in uiwrapper.dll
An unhandled exception of type 'System.AccessViolationException' occurred in uiwrapper.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
The debugger dialog error is:
Exception thrown at 0x0000000000000000 in ArcGISPro.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
This occurs before the body of the legacy ExportConfigDlg constructor begins execution, which suggests it is occurring within the wxPropertySheetDialog constructor, but I have not been able to get the debugger to step into that. It is implemented in wx/generic/propdlg.h.
This is how ConfigCreate() is being called from the C++/CLI project. To simplify things, instead of passing the HWND from a host application window, I'm passing the desktop window:
Code: Select all
bool ok = ConfigCreate(GetDesktopWindow());
Code: Select all
bool DECLSPEC ConfigCreate(HWND hWnd)
{
if ((::root) || (::config)) // test static variables
return false;
bool retval = wxEntryStart(GetModuleHandle(NULL), NULL, NULL, SW_SHOWNORMAL);
if ((retval) && (wxTheApp))
{
::root = new guikit::ModalRoot((WXHWND)hWnd); // ModalRoot tracks the parent
if (!::root)
return false;
wxTheApp->SetTopWindow(hWnd ? static_cast<wxWindow*>(*root) : (wxWindow*)NULL);
::config = new ExportConfigDlg((wxWindow*) *root, _wc("Export Configuration")); // *** exception occurs within this constructor ***
if (!::config)
{
delete ::root;
::root = 0;
return false;
}
}
else
{
return false;
}
return true;
}
Code: Select all
ExportConfigDlg::ExportConfigDlg(wxWindow* parent, const wxString& title) :
wxPropertySheetDialog(parent,
wxID_ANY,
title,
parent->GetPosition(),
parent->GetSize(),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
exportPage_(0),
layerPage_(0),
attribPage_(0),
linkPage_(0),
shiftPage_(0),
notebook_(0)
{ // *** exception occurs here ***
notebook_ = dynamic_cast<wxNotebook*>(GetBookCtrl());
exportPage_ = new ExportPage(notebook_);
layerPage_ = new LayerPage(notebook_);
attribPage_ = new AttribPage(notebook_);
linkPage_ = new LinkPage(notebook_);
shiftPage_ = new ShiftPage(notebook_);
}
TIA,
Alan