怎么在visual studio 里开发 arcgis

怎么在visual studio 里开发 arcgis,第1张

如果是arcgis9.3,则应该对应的使用vs2008,在安装arcgis9.3时,会自动将arcgis工具箱控件添加到vs2008中,在2008中新建项目asp.net web 应用程序,然后将arcgis工具箱中所需的控件直接拖到项目的default.aspx中,配置控件的属性,这是最简单的,如果要求跟复杂的,需要深入的学习了

public static void InitLiscense() {

// Get the ArcGIS Engine runtime, if it is available

String arcObjectsHome = "E:\\Program Files\\ArcGIS\\Desktop10.0\\"

// If no runtime is available, exit application gracefully

if (arcObjectsHome == null) {

System.err

.println("You must have the ArcGIS Engine Runtime installed in order to execute this application.")

System.err

.println("Install the product above, then re-run this application.")

System.err.println("Exiting execution of this application...")

System.exit(-1)

}

// Obtain the relative path to the arcobjects.jar file

String jarPath = arcObjectsHome + "java" + File.separator + "lib"

+ File.separator + "arcobjects.jar"

// Create a new file

File jarFile = new File(jarPath)

// Test for file existence

if (!jarFile.exists()) {

System.err

.println("The arcobjects.jar was not found in the following location: "

+ jarFile.getParent())

System.err

.println("Verify that arcobjects.jar can be located in the specified folder.")

System.err

.println("If not present, try uninstalling your ArcGIS software and reinstalling it.")

System.err.println("Exiting execution of this application...")

System.exit(-1)

}

// Helps load classes and resources from a search path of URLs

URLClassLoader sysloader = (URLClassLoader) ClassLoader

.getSystemClassLoader()

Class<URLClassLoader> sysclass = URLClassLoader.class

try {

Method method = sysclass.getDeclaredMethod("addURL",

new Class[] { URL.class })

method.setAccessible(true)

method.invoke(sysloader, new Object[] { jarFile.toURI().toURL() })

} catch (Throwable throwable) {

throwable.printStackTrace()

System.err

.println("Could not add arcobjects.jar to system classloader")

System.err.println("Exiting execution of this application...")

System.exit(-1)

}

}

1. 首先是二次开发环境的安装(AE 10.1),需要装下面两项:

2. AE 10.1貌似只支持VS2010,VS2010以下的VS版本不支持,VS2012也不支持,安装了不支持的VS版本会出现以下提示:

3. 安装后在开发时可以添加引用来使用AE提供的接口,如下图:

4.在程序初始化之前需要检查AE组件的授权状态,代码如下:

[csharp] view plain copy

private void InitializeComponent()

{

IAoInitialize m_AoInitialize = new AoInitializeClass()

esriLicenseStatus esriLicenseStatuslicenseStatus = esriLicenseStatus.esriLicenseUnavailable

esriLicenseStatus licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo)

if (licenseStatus != esriLicenseStatus.esriLicenseAvailable)

{

System.Diagnostics.Trace.WriteLine("Invalid Licensing.")

return

}

......

假如组件完全没有授权,在调试时会出现下面错误提示:

假如有部分组件授权过期了,会提示你哪些组件过期了:


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/11554865.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存