Convert Labels To Annotation

644
1
Jump to solution
02-23-2013 12:09 AM
MihailTorohov
New Contributor
Hi all! Please help deal with the error when compiling the project.
Use VS 2010.

Here the code of the project:

using ESRI.ArcGIS.Carto;  using ESRI.ArcGIS.Display;  using ESRI.ArcGIS.Geodatabase;  using ESRI.ArcGIS.esriSystem;   namespace ArcMapAddin2  {      public class LabelToAnnotation : ESRI.ArcGIS.Desktop.AddIns.Button      {          public LabelToAnnotation()          {                        }           protected override void OnClick()          {              //              //  TODO: Sample code showing how to access button host              //              ConvertLabelsToAnnotationSingleLayerMapAnno(ArcMap.Document.FocusMap,0);          }          protected override void OnUpdate()          {              Enabled = ArcMap.Application != null;          }          static void ConvertLabelsToAnnotationSingleLayerMapAnno(IMap pMap, int layerIndex)          {              IConvertLabelsToAnnotation pConvertLabelsToAnnotation = new ConvertLabelsToAnnotationClass();              ITrackCancel pTrackCancel = new CancelTrackerClass();              //Change global level options for the conversion by sending in different parameters to the next line.              pConvertLabelsToAnnotation.Initialize(pMap,              esriAnnotationStorageType.esriMapAnnotation,              esriLabelWhichFeatures.esriVisibleFeatures, true, pTrackCancel, null);              ILayer pLayer = pMap.get_Layer(layerIndex);              IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;              if (pGeoFeatureLayer != null)              {                  IFeatureClass pFeatureClass = pGeoFeatureLayer.FeatureClass;                  //Add the layer information to the converter object. Specify the parameters of the output annotation feature class here as well.                  pConvertLabelsToAnnotation.AddFeatureLayer(pGeoFeatureLayer,                  pGeoFeatureLayer.Name + "_Anno", null, null, false, false, false, false,                  false, "" ;) ;                  //Do the conversion.                  pConvertLabelsToAnnotation.ConvertLabels();                  //Turn off labeling for the layer converted.                  pGeoFeatureLayer.DisplayAnnotation = false;                  //Refresh the map to update the display.                  IActiveView pActiveView = pMap as IActiveView;                  pActiveView.Refresh();              }          }      }  }


And here is the error:
Error 1 the type "ESRI.ArcGIS.Carto.ConvertLabelsToAnnotationClass" do not define a constructor
Error 2 the Introduction of the interaction type "ESRI.ArcGIS.Carto.ConvertLabelsToAnnotationClass" it's impossible. Use instead the available interface.
Error 3 For type "ESRI.ArcGIS.Display.CancelTrackerClass" do not define a constructor.
Error 4 Introduction of interaction type "ESRI.ArcGIS.Display.CancelTrackerClass" it's impossible. Use instead the available interface.
0 Kudos
1 Solution

Accepted Solutions
MihailTorohov
New Contributor
Damn, the error was in the version of the .NET 4. Requires version 3.5.

View solution in original post

0 Kudos
1 Reply
MihailTorohov
New Contributor
Damn, the error was in the version of the .NET 4. Requires version 3.5.
0 Kudos