PROBLEM
A System.NullReferenceException is thrown when using the the sceneTools.dll generated by the C# sample. The crash can be reproduced using the steps below:
1. The following sample is built to create the sceneTools.dll: <DeveloperKit install Location>\SamplesNET\Engine\ControlsCommandsSceneCommands.
2. Create an application that contains a ToolbarControl.
3. Add the ZoomIn and ZoomOut tools from the sample to the application’s ToolbarControl in Visual Studio designer, programmatically or by customizing the control at runtime.
The crash may occur when adding the tools, while building the application, or when exiting the application.
The Custom Scene Navigation Command sample has two commands that do not check for 'null' in the destructors. The Destructor methods are ~ZoomIn() and ~ZoomOut() These methods do not check for null m_pen and m_brush objects before calling the Dispose method. The Destructor method of ZoomIn and ZoomOut is as follows:
Code:
[C#]
~ZoomIn()
{
m_pSceneHookHelper = null;
m_pCursor = null;
m_pen.Dispose();
m_brush.Dispose();
}
Get help from ArcGIS experts
Download the Esri Support App