Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is a problem my coworkers and I have encountered several times without being able to track down the exact issue, and a very annoying and almost untestable one.

When testing a standalone application using ArcObjects, at the some point the license would end up corrupted and impossible to repair without contacting ESRI support.

A sample of the latest application in development that corrupted my license recently:

[STAThread]
static void Main(string[] args)
{
     AoInitialize arcObjectInitialize = null;


    if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop))
    {
        System.Console.WriteLine("This application could not load the correct version of ArcGIS.");
        Environment.Exit(Environment.ExitCode);
    }

    try
    {
        arcObjectInitialize = new AoInitialize();
        esriLicenseProductCode typeLicense;

        if (arcObjectInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeBasic) == esriLicenseStatus.esriLicenseAvailable)
        {
            typeLicense = esriLicenseProductCode.esriLicenseProductCodeBasic;
            arcObjectInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeBasic);
        }
        else
        {
            if (arcObjectInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeStandard) == esriLicenseStatus.esriLicenseAvailable)
            {
                typeLicense = esriLicenseProductCode.esriLicenseProductCodeStandard;
                arcObjectInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
            }
            else
            {
                if (arcObjectInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeAdvanced) == esriLicenseStatus.esriLicenseAvailable)
                {
                    typeLicense = esriLicenseProductCode.esriLicenseProductCodeAdvanced;
                    arcObjectInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
                }
                else
                {
                    throw new Exception("ArcView");
                }
            }
        }
    }
    catch
    {
        Console.WriteLine("No valid license found, exiting program.");
        Environment.Exit(Environment.ExitCode);
    }


    //Some processings...


    try
    {
        arcObjectInitialize.Shutdown();
    }
    catch
    {
        Console.WriteLine("License shutdown failed, exiting program.");
        Environment.Exit(Environment.ExitCode);
    }
}

It follows the examples given on the support, but if there is something more to check or something that shouldn't be done, I woul be really glad to know what. The latest corruption happened while ArcMap was running in background, should it be avoided ? Is it a known issue or is there a way to check if the license is in use ?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.