• 用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;
       }

  • 相关阅读:
    协方差的意义
    ios7新特性实践
    微信支付大盗--黑色产业链
    UVA 297 Quadtrees(四叉树建树、合并与遍历)
    HDU 2876 Ellipse, again and again
    java中接口的定义与实现
    Oracle Linux 6.3下安装Oracle 11g R2(11.2.0.3)
    Fortran使用隐形DO循环和reshape给一维和多维数组赋初值
    Java实现 蓝桥杯VIP 算法训练 成绩的等级输出
    Java实现 蓝桥杯VIP 算法训练 成绩的等级输出
  • 原文地址:https://www.cnblogs.com/shengfly/p/6169660.html
Copyright © 2020-2023  润新知