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();
     }
    }

  • 相关阅读:
    basic use of sidekiq
    查看远程git log
    通过rails console执行sql语句
    通过rails打开数据库
    如何用rake tasks 生成migration对应的sql
    Remainders Game (中国剩余定理)
    binary-tree-preorder-traversal
    minimum-depth-of-binary-tree (搜索)
    Find a multiple POJ
    linked-list-cycle (快慢指针判断是否有环)
  • 原文地址:https://www.cnblogs.com/threestone/p/1781396.html
Copyright © 2011-2022 走看看