ERROR
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)).
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.
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) { .... } }
Get help from ArcGIS experts
Download the Esri Support App