zoukankan      html  css  js  c++  java
  • ArcEngine开发 退出系统报错

    主要原因是没有释放AO资源

    public class Form1 : System.Windows.Forms.Form
    {
        private ESRI.ArcGIS.esriSystem.IAoInitialize m_AoInitialize = new ESRI.ArcGIS.esriSystem.AoInitializeClass();

        private void Form1_Load(object sender, System.EventArgs e)
        {
            // 创建新的AoInitialize对象
            if ( m_AoInitialize == null)
            {
                System.Windows.Forms.MessageBox.Show("初始化失败,程序不能运行!");
                this.Close();
            }
            // 判断产品是否有效
            ESRI.ArcGIS.esriSystem.esriLicenseStatus licenseStatus = (esriLicenseStatus)
                m_AoInitialize.IsProductCodeAvailable(
                ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeEngine);
            if (licenseStatus == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable )
            {
                licenseStatus = (ESRI.ArcGIS.esriSystem.esriLicenseStatus)
                    m_AoInitialize.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeEngine);
                if (licenseStatus != ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseCheckedOut )
                {
                   System.Windows.Forms.MessageBox.Show("初始化失败,应用程序不能运行!");
                   this.Close();
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("ArcGIS Engine产品无效,此程序不能运行!");
                this.Close();
            }
        }
      
        private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // 释放COM对象并关闭AoInitialize对象
            ESRI.ArcGIS.Utility.COMSupport.AOUninitialize.Shutdown();
            m_AoInitialize.Shutdown();
     }
    }

  • 相关阅读:
    Armijo线性搜索
    numpy 常用工具函数 —— np.bincount/np.average
    理解Buffer
    Node.js 文件系统fs模块
    NodeJS遍历文件生产文件列表
    windows 环境下node开发环境搭配问题
    npm国内镜像
    node+express实现文件上传功能
    Coding 代码管理快速入门(转)
    Node学习HTTP模块(HTTP 服务器与客户端)
  • 原文地址:https://www.cnblogs.com/threestone/p/1781396.html
Copyright © 2011-2022 走看看