zoukankan      html  css  js  c++  java
  • 用IFeatureWorkspaceAnno.CreateAnnotationClass 创建注记图层时报“The application is not licensed to modify or create schema”的错误的解决方案。

    用IFeatureWorkspaceAnno.CreateAnnotationClass 的方法创建注记图层的时候报“The application is not licensed to modify or create schema”的错误。

    下面是测试代码:

    public ESRI.ArcGIS.Geodatabase.IFeatureClass CreateFeatureClass(IFeatureLayer fLyr,double referenceScale, IWorkspace2 workspace,IFeatureDataset featureDataset, String featureClassName,IFields fields,
    ESRI.ArcGIS.esriSystem.UID CLSID, ESRI.ArcGIS.esriSystem.UID CLSEXT, System.String strConfigKeyword)
     {
    
           if (featureClassName == "") return null; // name was not passed in
    
           ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = null;
           IFeatureWorkspaceAnno annoFWorkspace = workspace as IFeatureWorkspaceAnno;
           ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace; // Explicit Cast
           if (workspace.get_NameExists(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass, featureClassName))
            {
               featureClass = featureWorkspace.OpenFeatureClass(featureClassName);
               return featureClass;
            }
                ISymbolCollection2 symbolCol=new SymbolCollectionClass ();
                IAnnotateLayerPropertiesCollection annoLPColl=new AnnotateLayerPropertiesCollectionClass ();
                InnitAnno(fLyr,ref symbolCol ,ref annoLPColl);
    
                IGraphicsLayerScale glScal=new GraphicsLayerScaleClass ();
                glScal .ReferenceScale =referenceScale;
    
                IFeatureClassDescription fcDescription = new AnnotationFeatureClassDescriptionClass();
    
                ESRI.ArcGIS.Geodatabase.IObjectClassDescription objectClassDescription = fcDescription as IObjectClassDescription;
    
                featureClass = annoFWorkspace.CreateAnnotationClass(featureClassName, objectClassDescription.RequiredFields,                                    objectClassDescription.InstanceCLSID, objectClassDescription.ClassExtensionCLSID,
                 fcDescription.ShapeFieldName, null, featureDataset, fLyr.FeatureClass, annoLPColl, glScal, symbolCol, true);
    
                AlterSpatialReference(featureClass, (fLyr.FeatureClass as IGeoDataset).SpatialReference)
    
                return featureClass;
       }

    报错原因:

    在创建注记图层、对SDE里数据进行编辑时,以及需要在SDE和Personal Geodatabase中创建复杂ArcGIS对象时时候需要ArcGIS Engine Enterprise Geodatabase(以下简称GDB Update)许可,但在一般情况下,我们会用将LicenseControl拖放到主窗体上完成初始化。但当Engine程序需要使用ArcGIS Engine Enterprise Geodatabase(以下简称GDB Update)许可的时候,我们就往往会由于意识不到应该使用该许可,以及无法正确的初始化该许可而陷入麻烦。

    解决方案:

    第一种:使用LicenseControl控件。将该控件拖放到主窗体之上,勾选适当的许可,并确保程序启动该窗体可加载,就可以完成许可初始化。如下图:

    第二种:

     使用IAoInitialize.Initialize方法加入适当的参数进行初始化。

     C#代码如下:

    private static bool CheckLicenses()
    {
           //绑定权限
           ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

           //初始化权限
           IAoInitialize m_AoInitialize =new AoInitializeClass();

           //Create a new AoInitialize object
           if (m_AoInitialize == null)
           {
                    MessageBox.Show("初始化授权失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   return false;
           }
          //Determine if the product is available
          esriLicenseStatus licenseStatus =                    (esriLicenseStatus)m_AoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
           if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
           {
               licenseStatus = (esriLicenseStatus)m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
               if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
              {
                   MessageBox.Show("初始化授权失败,程序退出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
              }
          }
          else
          {
               MessageBox.Show("ArcEngine授权无效,程序退出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
               return false;
          }
           return true;
       }

  • 相关阅读:
    Linux几个常用的目录结构
    Linux 安装composer
    Elasticsearch修改network后启动失败
    php7 闭包调用
    php 爬虫框架
    file_get_contents('php://input') 和POST的区别
    PHP指定日期转时间戳
    .Net 站点跨域问题及解决方法
    C# 多线程学习系列一
    Nginx学习系列四默认负载均衡轮询及Ip_hash等常用指令介绍
  • 原文地址:https://www.cnblogs.com/shengfly/p/6169660.html
Copyright © 2011-2022 走看看