ERROR

Unable to cast COM object of type 'ESRI.ArcGIS.esriSystem.AoInitializeClass' to interface type 'ESRI.ArcGIS.esriSystem.IAoInitialize'

Last Published: April 25, 2020

Error Message

Attempts to run an ArcGIS Engine app return the following error:

Error:   
Unable to cast COM object of type 'ESRI.ArcGIS.esriSystem.AoInitializeClass' to interface type 'ESRI.ArcGIS.esriSystem.IAoInitialize'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{someGUID}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002001D (TYPE_E_LIBNOTREGISTERED)).

Cause

The app is not declared as a Single Threaded Apartment (STA) app. This can occur if a new application is created in ArcGIS Engine without using the Esri-provided template.

Solution or Workaround

To resolve this issue, add an attribute at the top of the ArcGIS Engine app to declare it as a Single Threaded Application (STA). For example:

class Program
{
    private static LicenseInitializer m_AOLicenseInitializer = new EngineConsoleApp_ESRI.LicenseInitializer();

    [STAThread()]
    static void Main(string[] args)
    {
        ....
    }
}

Article ID:000020746

Software:
  • ArcObjects SDK Microsoft NET Framework

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options