当前位置: 代码迷 >> GIS >> WPF上Arc Lisence的有关问题
  详细解决方案

WPF上Arc Lisence的有关问题

热度:129   发布时间:2016-05-05 06:24:42.0
WPF下Arc Lisence的问题
代码如下:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
//using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;

namespace DigitalHomeDesktop
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    /// 初始化权限
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
            InitializeEngineLincense();
        }

        private void InitializeEngineLincense()
        {
            AoInitialize aoi = new AoInitializeClass();
            esriLicenseProductCode productcode = esriLicenseProductCode.esriLicenseProductCodeEngine;
            if (aoi.IsProductCodeAvailable(productcode) ==esriLicenseStatus.esriLicenseAvailable)
            {
                aoi.Initialize(productcode);
            }
            //throw new NotImplementedException();
        }//设置权限方法

     

    }
}


和ArcGIS的帮助文档里的例子基本上一样,就是不知道为什么还报错。
异常信息如下:
未处理 System.Runtime.InteropServices.COMException
  Message=ArcGIS product not specified.  You must first bind to an ArcGIS version prior to using any ArcGIS components.
  Source=esriSystem.AoInitialize
  ErrorCode=-2147221002
  StackTrace:
       在 ESRI.ArcGIS.esriSystem.AoInitializeClass.IsProductCodeAvailable(esriLicenseProductCode ProductCode)
       在 DigitalHomeDesktop.App.InitializeEngineLincense() 位置 E:\ArcGIS\DigitalHomeDesktop\DigitalHomeDesktop\App.xaml.cs:行号 29
       在 DigitalHomeDesktop.App.OnStartup(StartupEventArgs e) 位置 E:\ArcGIS\DigitalHomeDesktop\DigitalHomeDesktop\App.xaml.cs:行号 22
       在 System.Windows.Application.<.ctor>b__0(Object unused)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)