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(); }//设置权限方法 }}
在 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;
}
}