ArcGIS10+版本,使用VS建立一個簡單的AE應用程式,然後拖放一個toolbar、LicenseControl以及MapControl控件。
接着編譯應用程式,編譯成功。
然後單擊F5運作程式,這個時候程式報錯,出現下面所示的錯誤:
ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS components.
問題解決方案:
在系統的入口添加下面的一行代碼:
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
當然上面這樣代碼也可以添加到其他的适合的位置,本人感覺放到程式的入口最合适
這裡還需要添加一個Reference:ESRI.ArcGIS.Version
完整的參考代碼如下所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}