Select to view content in your preferred language

Error of re-adding shapefiles into AGX

717
1
06-24-2010 11:43 AM
Yi-ChenYang
Emerging Contributor
Dear all,
I am using AGX SDK (VB2008) to build a customized interface

I create one button to add the shpaefile as featurelayer into AGX

code:
Dim TestLayer As FeatureLayer
TestLayer=FeatureLayer.OpenShapefile("C:\test.shp")
map.ChildItems.Add(TestLayer)

I also create another button to remove it

code:
TestLayer.RemoveFromParent()
TestLayer.ClearCache()
TestLayer.Disconnect()

But when I remove the shapefile and want to add it again, I got this error message:
"Failed to create a valid association from a featurelayer to a table"

I am not quite understand what is that mean, can anyone help me here?

Thanks a lot in advance.

Ethan
0 Kudos
1 Reply
MichaelBranscomb
Esri Frequent Contributor
Ethan,

You might like to try using:

Application.ActiveMapDisplay.Map.ChildItems.Remove(TestLayer)

This works fine - as does re-adding the layer afterwards using the OpenShapefile method in your example code.

Calling Disconnect() is probably unnecessary (and may be the cause of your problem - unfortunately I didn't go as far as to test this) but you can call ClearCache() if you want to explicitly clear out the disk cache.

Regards

Mike
0 Kudos