3

I have a Student Edition of ArcGIS 10.1 for Desktop Advanced. My license is set up on my machine as single use. I am trying to initialize the license in ArcObjects, however I get the following error:

"ArcGIS product not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components."

This occurs when I call AoInitialize.IsProductCodeAvailable() which doesn't make sense, since that is how you figure out what license to initialize in the first place. Here is my code:

public static esriLicenseStatus Intialize(
        ESRI.ArcGIS.esriSystem.esriLicenseProductCode esriLicenseProductCode)
    {
        IAoInitialize aoInitialize = new AoInitialize();
        esriLicenseStatus esriLicenseStatus = 
            aoInitialize.IsProductCodeAvailable(esriLicenseProductCode);

        if (esriLicenseStatus == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable)
            esriLicenseStatus = 
                aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);

        return esriLicenseStatus;
    }

What am I doing wrong? Does this have to do with it being Student Edition?

lintmouse
  • 307
  • 4
  • 10

2 Answers2

2

Try this code using the RuntimeManager class, makes it much simpler:

    if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
        ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

You'll need to add a reference to the ESRI.ArcGIS.Version assembly.

blah238
  • 35,793
  • 7
  • 94
  • 195
0

I have this problem too. This exception throws when I call AoInitialize.Initialize().

I use WPF and winform MapView control.

This exception is thrown when I call .Initialize() in BackgroundWorker in splash window. I bind product code to runtime in application start up and Initialize method run successfully.

Private Sub Application_Startup_1(sender As Object, e As StartupEventArgs)
        If Not ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine) Then
            If Not ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop) Then
                MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
            End If
        End If
        Dim _initialize As New AoInitializeClass()
        _initialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB)
        _splash = New SplashScreen()
        _splash.ShowDialog()
End Sub

All thing become ok.

mgri
  • 16,159
  • 6
  • 47
  • 80
Mehdi
  • 147
  • 4