ArcGIS 9.3.1 VB.NET IDockableWindowDef error

Discussion created by ksurbell21 on Apr 19, 2011

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 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 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" (see below), do I also need to hook within the button click on the form or the form load?

Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.Framework.IDockableWindowDef.OnCreate

        m_application = hook
        m_pMxDoc = m_application.Document

End Sub

Thank you