When I used wpf for overlay analysis, I encountered an ERROR: "ERROR 010096: no Spatial Analyst permission is currently enabled or not "; the Spatial Analyst Extension function is checked in the environment and cannot be solved. Now, I will write down the solution for your reference:
The solution is to add a sentence when initializing the license in the app. The following is the license code of my app. cs in the app class.
// Set a license for alicense
// Of course, some class libraries must be referenced here, which are all built-in with arcgis.
Protected override void OnStartup (StartupEventArgs e)
{
ESRI. ArcGIS. RuntimeManager. Bind (ESRI. ArcGIS. ProductCode. EngineOrDesktop );
Initlicense ();
// The pop-up form is displayed. The app foreground removes startupUri. Otherwise, two forms will pop up.
New Arcmap (). Show ();
}
Public void initlicense ()
{
AoInitialize aoi = new AoInitialize ();
EsriLicenseExtensionCode extensionCodes = esriLicenseExtensionCode. esriLicenseExtensionCodeSpatialAnalyst; // This is the solution
EsriLicenseExtensionCode extensionCode = esriLicenseExtensionCode. esriLicenseExtensionCode3DAnalyst;
EsriLicenseProductCode pro = esriLicenseProductCode. esriLicenseProductCodeEngine;
If (aoi. IsProductCodeAvailable (pro) = esriLicenseStatus. esriLicenseAvailable &&
Aoi. IsExtensionCodeAvailable (pro, extensionCode) = esriLicenseStatus. esriLicenseAvailable &&
Aoi. IsExtensionCodeAvailable (pro, extensionCodes) = esriLicenseStatus. esriLicenseAvailable
)
{
Aoi. Initialize (pro );
Aoi. CheckOutExtension (extensionCode );
Aoi. CheckOutExtension (extensionCodes );
}
}
The attributes in esriLicenseExtensionCode have many loading methods similar to those above.