I managed to fix the problem by hooking the following code into the map dispose:
foreach (Overlay overlay in gisMap.Overlays) { if (overlay is LayerOverlay) { LayerOverlay layerOverlay = overlay as LayerOverlay; foreach (var layer in layerOverlay.Layers) { if (layer is ShapeFileFeatureLayer) { ShapeFileFeatureLayer shapeFileFeatureLayer = layer as ShapeFileFeatureLayer; if (shapeFileFeatureLayer.IsOpen) { shapeFileFeatureLayer.Close(); } } } layerOverlay.Layers.Clear(); } }
The question now is - if opening a map locks the layers, how can I open 2 maps using the same shape files?
I think you get the right solution for the issue raised at the beginning of the thread. Now, the problem you mentioned at last is related with the ReadWriteMode set to the ShapeFileFeatureLayer.
We allow multiple access to the ReadOnly mode and unique access to the ReadWrite mode to the shape file which is compatible with the Microsoft file read logic. So, I think when 2 or more maps access the same shape files with ReadOnly mode, that is reasonable . Any more questions just feel free to let me know.
I was fairly sure the dispose of the Desktop Edition did loop through all of the layers and close them. We will check into that and make sure this is still the case.
Yea, I confirmed that. :-) I thought we closed the layers but at the map level there is only the Overlays and not the layers. I am considering now adding a dispose to the overlays and then in the map’s dispose call the overlays dispose then we can add the logic on our end to loop through all of the layers and close them. I will keep you posted on what we decide to do on this. Your method is going to work but I think we can do something to prevent you have having to do this.
We are going to move forward with the dispose. Give us a little time as it has to go through review etc. It should be in by early next week though. We plan to update all the overlay types to make sure everything is closed. Thanks for reporting this. In my mind we were already doing that, its hard to keep 20 version of Map Suite in my head. :-)
I’m supporting a current version of our app that uses V2 and developing a new version with V4. Even worse the current version is VB.Net and the new one is C#. Talk about confusing!