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

最新文章

  1. iOS通过ARC管理内存(内容根据iOS编程编写)
  2. ACM/ICPC 之 Bellman Ford练习题(ZOJ1791(POJ1613))
  3. vb6 获取 http only 的 Cookie
  4. android 解析XML方式(一)
  5. Android - Unable to execute dex: Multiple dex files define
  6. 支付返回post请求数据
  7. Django 安装MySQLdb模块
  8. idea git 注意事项
  9. .NET自带缓存机制实例
  10. EBS 信用检查(二)
  11. SQL SERVER 索引碎片
  12. s2第六章继承和多态
  13. fill和memset的区别
  14. android中动态修改ImageView控件的宽高度
  15. struts 2中为什么抽象包不能包含action?
  16. java类的初始化的默认值
  17. poj2262 Goldbach's Conjecture
  18. XCODE5 真机測试
  19. redis_学习_02_redis 可视化工具 Redis Desktop Manager
  20. maven profile启动项目

热门文章

  1. javascript第三章--引用类型
  2. 【Win 10 应用开发】UI Composition 札记(八):用 XamlLight 制作灯光效果
  3. Ionic3学习笔记(十一)实现省市区三级联动
  4. webpack 3.X学习之CSS处理
  5. ConstraintLayout
  6. 微软云计算 Massive Data 处理语言Scope 1
  7. 计算生日是星期几-soj
  8. 【原创】python基于大数据现实双色球预测
  9. SSL/TLS 握手过程详解
  10. Centos7.0 安装 oracle 11g 以及相关问题解决