Convert Labels to Annotations .NET Sample

5124
5
03-11-2015 10:04 AM
Corbinde_Bruin
Occasional Contributor II

Goal: Convert labels to Annotations using ArcObjects.

Method: I ran an ESRI code sample from the documentation and received this error:

"A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in GdB Subsurface Investigation v103.dll

Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.

If there is a handler for this exception, the program may be safely continued."

Code sample found here: Covert Labels Sample Code

This is call I make to the function: ConvertLabelsToGDBAnnotationSingleLayer(pMap, 0, False)

pMap is a properly declared and set IMap object.

There is only one layer in the MXD, and I have confirmed (as expected) that it is found at index 0.

The last parameter is a boolean to set Feature Linked annotations.

The error occurs on this line:

pConvertLabelsToAnnotation.AddFeatureLayer(pGeoFeatureLayer, pGeoFeatureLayer.Name & "_Anno",  pFeatureWorkspace, pFeatureClass.FeatureDataset, featureLinked, False, False, True, True, "")

Also, is there a way to use code tags in this forum?

0 Kudos
5 Replies
AlexanderNohe1
Occasional Contributor III

Hello Corbin de Bruin​,

1)  What version of ArcMap are you using? (10.1, 10.2, ...)

2)  What license level do you have for Arc Map? (Basic, Standard, Advanced)

3)  What service packs do you have installed?

4)  What operating system are you using?

5)  Do you have data interop installed?

6)  Are you using VB.NET or C#?

Thanks!

0 Kudos
Corbinde_Bruin
Occasional Contributor II

This is just becoming an issue again.

1)  What version of ArcMap are you using? (10.1, 10.2, ...)

ArcDesktop 10.3.0

2)  What license level do you have for Arc Map? (Basic, Standard, Advanced)

Advanced

3)  What service packs do you have installed?

Not sure.

4)  What operating system are you using?

Windows 7

5)  Do you have data interop installed?

No

6)  Are you using VB.NET or C#?

VB.NET

0 Kudos
AlexanderNohe1
Occasional Contributor III

Hi Corbin de Bruin​,

After doing some additional testing on my end, I was able to reproduce the issue that you are seeing only when the layer of index value 0 was not labeled.  Can you make sure that this layer is labeled when you run the sample and try again?

Thanks,

Alexander N.

0 Kudos
Corbinde_Bruin
Occasional Contributor II

This is becoming an issue again.

I ensured the labels were on and ran again. Same issue.

0 Kudos
OwenEarley
Occasional Contributor III
Also, is there a way to use code tags in this forum?

Click on the link to Use advanced editor, then:

  • highlight the code to format,
  • click on the >> (insert) button
  • select Syntax Highlighting > then pick a language
0 Kudos