HOW TO

Dynamically add Map Control to an application using Visual Basic .NET

Last Published: April 25, 2020

Summary

** Internal Publish Only! This article may contain information that is not intended for external circulation. **

A license key is required when you distribute a dynamically created Map Control. This article shows how to programmatically add a Map Control to Visual Basic .NET application using a license key.

Procedure

The license key for MapObjects is "Copyright (c) 1999 ESRI, Inc.". The license key is located in the MO20.lic file.

  1. Start a new Visual Basic .NET application and click Project > Add Reference.

    Click the .NET tab and select the following assmeblies:

    Code:
    MapObjects2 Core Interop Assembly
    MapObjects2 AxMap Host Interop Assembly

    If the application requires MemTable and Custom extension libraries, select the following assemblies:

    Code:
    MapObjects2 Custom Interop Assembly
    MapObjects2 MemTable Interop Assembly

  2. Add a Button control to the form and in the button's click event paste the following code:

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    'create a new instance of Map Control
    Dim mMap As New ESRI.MapObjects2.Core.AxMap()

    'Add MapObjects license key to the control
    Dim f As System.Reflection.FieldInfo
    f = GetType(AxHost).GetField("licenseKey", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
    f.SetValue(mMap, "Copyright (c) 1999 ESRI, Inc.")

    'Add Map Control to the Form
    Controls.Add(mMap)
    mMap.Show()

    End Sub


    Note:
    The string 'licenseKey' is case sensitive.

Article ID:000006248

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options