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)

在 System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
       在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       在 System.Threading.ExecutionContext.runTryCode(Object userData)
       在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Windows.Threading.DispatcherOperation.Invoke()
       在 System.Windows.Threading.Dispatcher.ProcessQueue()
       在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       在 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)
       在 System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       在 System.Windows.Threading.Dispatcher.Run()
       在 System.Windows.Application.RunDispatcher(Object ignore)
       在 System.Windows.Application.RunInternal(Window window)
       在 System.Windows.Application.Run(Window window)
       在 System.Windows.Application.Run()

在 DigitalHomeDesktop.App.Main() 位置 E:\ArcGIS\DigitalHomeDesktop\DigitalHomeDesktop\obj\x86\Debug\App.g.cs:行号 0
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
------解决方案--------------------
你用的是arcgis10吧?
提示信息:ArcGIS product not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components.
Source=esriSystem.AoInitialize

在注册前加多下面几句试试:
if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine))
            {
                if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop))
                {
                    System.Console.WriteLine("This application could not load the correct version of ArcGIS.");
                    return;
                }
            }

最新文章

  1. .net 分布式架构之分布式缓存中间件
  2. window 下 xampp 上 安装memcached
  3. 如何将C#类库做成COM
  4. Can only set Cookies for the current domain
  5. iOS手机功能汇总
  6. php 获取当前用户的IP
  7. HTML5实战——svg学习
  8. UVa11218 KTV
  9. andriod ADB命令的使用
  10. 生成N个不相等的随机数
  11. TDirectory.GetLogicalDrives获取本地逻辑驱动器
  12. Find them, Catch them(POJ 1703 关系并查集)
  13. 桦仔 笔记7-徐 SQLSERVER日志记录机制
  14. 帝国cms7.0忘记后台管理账户用户名密码
  15. Apache添加mime类型
  16. 201521123114 《Java程序设计》第10周学习总结
  17. C# 委托详解(一)
  18. Java Thread wait、notify与notifyAll
  19. 常见的if语句shell脚本
  20. C++对C的函数拓展 - 占位参数

热门文章

  1. 使用LVM对硬盘在线扩容
  2. 使用 JavaScript 实现链表
  3. Any changes made by a writer will not be seen by other users of the database until the changes have been completed
  4. Jquery中的队列函数quene()、dequene()、clearQuene()
  5. The Python Tutorial
  6. 参数中带有“&amp;”符号问题
  7. 由FutureTask的get方法靠什么机制来阻塞引发的思考
  8. TCP/IP详解--发送ACK和RST的场景
  9. [翻译] 为什么Uber的数据库从Postgres 切换到 MySql
  10. Leetcode: Number of Segments in a String