ArcObjects Library Reference  

LicenseInitializer

About the Clonable object Sample

[C#]

LicenseInitializer.cs

using System;
using ESRI.ArcGIS;

namespace TestApp
{
  internal partial class LicenseInitializer
  {
    public LicenseInitializer()
    {
      ResolveBindingEvent += new EventHandler(BindingArcGISRuntime);
    }

    void BindingArcGISRuntime(object sender, EventArgs e)
    {
      //
      // TODO: Modify ArcGIS runtime binding code as needed; for example, 
      // the list of products and their binding preference order.
      //
      ProductCode[] supportedRuntimes = new ProductCode[] { 
        ProductCode.Engine, ProductCode.Desktop };
      foreach (ProductCode c in supportedRuntimes)
      {
        if (RuntimeManager.Bind(c))
          return;
      }

      //
      // TODO: Modify the code below on how to handle bind failure
      //

      // Failed to bind, announce and force exit
      Console.WriteLine("ArcGIS runtime binding failed. Application will shut down.");
      System.Environment.Exit(0);
    }
  }
}
[Visual Basic .NET]

LicenseInitializer.vb

Imports ESRI.ArcGIS
Imports System

Partial Friend Class LicenseInitializer

  Public Sub New()

  End Sub

  Private Sub BindingArcGISRuntime(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResolveBindingEvent
    '
    ' TODO: Modify ArcGIS runtime binding code as needed; for example, 
    ' the list of products and their binding preference order.
    '
    Dim supportedRuntimes() As ProductCode = New ProductCode() {ProductCode.Engine, ProductCode.Desktop}
    For Each c As ProductCode In supportedRuntimes
      If (RuntimeManager.Bind(c)) Then Return
    Next

    '
    ' TODO: Modify the code below on how to handle bind failure
    '

    ' Failed to bind, announce and force exit
    Console.WriteLine("ArcGIS runtime binding failed. Application will shut down.")
    End
  End Sub

End Class