In my VB.NET application, I am using ArcObjects 10.4 and I am initializing ArcGIS. I load a feature class from a shapefile. The problem is that I get an HRESULT error 0x80040228, which is 2147220952 in decimal and it means "License not intialized" as you can see on this website: http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000000mn000000

The strange thing is, I load two feature classes. One from a shapefile, then another from a file geodatabase. As I said, loading from the shapefile crashes, but not from the FGDB. Also, if I invert the two LoadFeatureLayer lines, the FGDB feature class loads, and then, the shapefile feature class loads too. I tried with different features classes, the result is the same.

Is it a normal behavior?

Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.esriSystem

Public Class frm_Loading
Public aoInit As IAoInitialize

Private Sub frm_Loading_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    LoadFeatureLayer("export_output_2.shp", "c:\temp")
    LoadFeatureLayer("C_R137_CH", "c:\temp\FGDB.gdb", True)
End Sub

Public Sub InitializeArcGIS()
    If aoInit Is Nothing Then
        If ESRI.ArcGIS.RuntimeManager.ActiveRuntime Is Nothing Then
        End If

        aoInit = New AoInitialize
    End If
End Sub

Public Function LoadFeatureLayer(ByVal layer As String, ByVal cheminWorkspace As String, Optional FGDB As Boolean = False) As IFeatureLayer
    Dim aWorkspaceFactory As IWorkspaceFactory = Nothing
    Dim aFeatureWorkspace As IFeatureWorkspace = Nothing
    Dim aFeatureLayer As IFeatureLayer
        If FGDB Then
            Dim t As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory")
            Dim obj As System.Object = Activator.CreateInstance(t)
            aWorkspaceFactory = obj
            Dim t As Type = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory")
            Dim obj As System.Object = Activator.CreateInstance(t)
            aWorkspaceFactory = obj
        End If
        aFeatureWorkspace = aWorkspaceFactory.OpenFromFile(cheminWorkspace, 0)
        aFeatureLayer = New FeatureLayer
        aFeatureLayer.FeatureClass = aFeatureWorkspace.OpenFeatureClass(layer)
        aFeatureLayer.Name = aFeatureLayer.FeatureClass.AliasName
        Return aFeatureLayer

    Catch ex As Exception
        Return Nothing
        If aWorkspaceFactory IsNot Nothing Then System.Runtime.InteropServices.Marshal.FinalReleaseComObject(aWorkspaceFactory)
        If aFeatureWorkspace IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(aFeatureWorkspace)
    End Try
End Function
End Class
  • 1
    If you can create a WorkspaceFactory then I would expect your license is working. What line actually throws the exception when it fails? Also try removing the '.shp' from your call to LoadFeatureLayer.
    – danielm
    Jan 29, 2019 at 16:47
  • The error happens at the line aWorkspaceFactory.OpenFromFile. I also tried to remove the SHP and it changes nothing.
    – Math
    Jan 29, 2019 at 18:14
  • I have tested and run your code and run it without any issues (shapefile first). Have you tested any other shapefiles? ArcMap does give unrelated error messages from time to time.
    – danielm
    Jan 29, 2019 at 18:43
  • I tested other shapefiles and it doesn't work. But I have just tested it on a machine with ArcGIS 10.2 and it works. It feels like a ArcGIS 10.4 problem. I will try other 10.4 machines and if it is still not working, I will send this case to ESRI. Thank you!
    – Math
    Jan 29, 2019 at 19:50


Browse other questions tagged or ask your own question.