Hi Everyone,
I am able to succesfully create a network dataset (NDS) from a shapefile programmatically. But, for some reasons when I add the NDS as network layer to a map programmatically, the map remains blank although the layer is listed in the ArcMap TOC, and shows all the properties of the NDS. What might I be doing incorrectly here? The code is pretty simple as shown below.
However, it displays fine when I add it from the ArcCatalog TOC, which leads me to the second question. The NDS doesn't automatically appear in the ArcCatalog TOC initially on creation so I have to manually refresh the TOC. Also, I am unable to delete the NDS in ArcCatalog due to some schema lock error. I get the lock error even when I do not try to add the layer to the map. Is there a way to release the lock?
Thanks,
Sanjay.
I am able to succesfully create a network dataset (NDS) from a shapefile programmatically. But, for some reasons when I add the NDS as network layer to a map programmatically, the map remains blank although the layer is listed in the ArcMap TOC, and shows all the properties of the NDS. What might I be doing incorrectly here? The code is pretty simple as shown below.
Code:
INetworkLayer networkLayer = new NetworkLayerClass();
networkLayer.NetworkDataset = networkDataset;
ILayer layer = (ILayer) networkLayer;
layer.Name = "Network Dataset";
IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument;
mxDocument.FocusMap.AddLayer(layer);
Thanks,
Sanjay.