---UPDATE--- see below
I have a scaling raster tool that I'm attempting to migrate from ArcGIS 9.3.1 VBA to VB.NET (Visual Studio 2010). I have a BaseTool that is used to put two graphic points defining the left and right extent of the image that I want to scale. After the second point is added to the view a form opens to input the scaling parameters. My issues is when I go to click the scale command button (within the form) I get the "Null Reference Exception was unhandled by user code, Object reference not set to an instance of an object", error. The error occurs on this line:
pMap = m_pMxDoc.FocusMap
I have my ESRI references imported into the project for both pMap and m_pMxDoc. It seems like the form is not hooked to the ArcMap document? I tried to hook the form on load via the code below, but I get the same error.
Private Sub frmScaling_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim hook As Object = Nothing
m_application = hook
m_pMxDoc = m_application.Document
End Sub
Any suggestions of what I'm missing would be greatly appreciated.
Thanks
---UPDATE---
I created the docable window class and memebers. The On Create sub now is:
Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.Framework.IDockableWindowDef.OnCreate
m_application = hook
m_pMxDoc = m_application.Document
End Sub
Now when I click the command button within my form to scale the image I get a LoaderLock error (Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang). The error is still on this line:
pMap = m_pMxDoc.FocusMap
Is this error present because my form is open while the scaling action is trying to take place? So, the hook is now on the member "On Create", do I also need to hook within the button click on the form?
Are there any other good VB.NET form/code examples within ArcMap that contain some sort of button that interacts with the ArcMap view? I have only found this one,