Visual Basic Arc Objects program compiles clean but give window "Initialization Error" with message The runtime application type must be specified before license initialization. How is that done?

373
2
01-07-2018 11:04 AM
ThomasDanninger
New Contributor II

I'm converting the VB program from Visual Studio 2008 to VS 2013 and from ArcMap 10.0 to 10.5. I got the program to compile clean but get the "Initialziation Error" when attempt to run. I'm running Windows 10 and dotnet 4.5 is specified.

0 Kudos
2 Replies
ModyBuchbinder
Esri Regular Contributor

Hi

Make sure you have Bind Method

ESRI.ArcGIS.RuntimeManager.Bind before license code. 
ThomasDanninger
New Contributor II

Thanks Mody.  I already had the following in before any calls to ArcObjects:

.. 

If Not RuntimeManager.Bind(ProductCode.Desktop) Then
      MessageBox.Show("Could not bind to Desktop")
End If

I do not get the message box.  The software runs until the first call to an ArcObject after this "If" statement then I get the Initialization-error box?

A bit more info might help:

The ArcObjects call routine that produces the initialization error window and no exception is:

Try
      pBaseDEMFac = New RasterWorkspaceFactory
      pBaseDEMRW = pBaseDEMFac.OpenFromFile(System.IO.Path.GetDirectoryName(strBaseDEM), 0)
      pBaseDEMDataset3 = pBaseDEMRW.OpenRasterDataset(System.IO.Path.GetFileName(strBaseDEM))
      '  Got it open so write it to registry...
      My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\Civil War\Hidden Height", "BaseRaster", strBaseDEM)

Catch ex As Exception
      If (MessageBox.Show("Unable to open Input Base DEM raster. Need additional help?", "Hidden Height", MessageBoxButtons.YesNo, MessageBoxIcon.Error)) = Windows.Forms.DialogResult.Yes       Then
            frmDiaExtraHelp.rtfExtraHelp.Text = strOpenError
            frmDiaExtraHelp.ShowDialog()
      End If
End Try

When I skip around the above Try to the next ArcObject I do get an exception but no initialization error box:

Try
      pSFFactory = New ShapefileWorkspaceFactory
      'strShapeDir = System.IO.Path.GetDirectoryName(strShape)
      pSFFeatureWorkspace = pSFFactory.OpenFromFile(System.IO.Path.GetDirectoryName(strShape), 0)
      strTestDir = System.IO.Path.GetDirectoryName(strShape)
      pShapeFile = pSFFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileName(strShape))

Catch ex As Exception
      If (MessageBox.Show("Unable to open Input observation points Shapefile. Need additional help?", "Hidden Height", MessageBoxButtons.YesNo, MessageBoxIcon.Error)) =             Windows.Forms.DialogResult.Yes Then
            frmDiaExtraHelp.rtfExtraHelp.Text = strOpenError
            frmDiaExtraHelp.ShowDialog()
      End If

      Exit Sub
End Try

I used model builder to test a raster copy tool from the toolbox and that worked just fine.  So, I'm obviously missing something in converting the VB software since it worked just fine in my old versions of both Visual Studio and ArcMap.

Took me a few days but I finally figured out what the simple "Initialization Error" windows was trying to tell me.  When I added licence checking there was a second screen that I neglected to add a check mark indicating my selection of a basic, standard or advanced (as I remember) application.  I clicked on advanced and it took off executing several arobjects before failing on a geoprocessing call of Extract raster by mask.   I'll work on that now.. 

0 Kudos