I am playing around with Layer Definitions for a ArcGISDynamicMapService. I have never done this before and I am stuck. When I run this nothing happens in my map. It seems like after it hits the dynamicServiceLayer.LayerDefinitions.Add(lDef); line it just stops without warning. I places a messagebox right after this line and it never shows. Any ideas? Thanks..
string myLayer = "PoliciesSDE";
ArcGISDynamicMapServiceLayer dynamicServiceLayer = MapApplication.Current.Map.Layers[myLayer] as ArcGISDynamicMapServiceLayer;
LayerDefinition lDef = new LayerDefinition();
lDef.LayerID = 0;
lDef.Definition = "State = 'OREGON'";
dynamicServiceLayer.LayerDefinitions.Add(lDef);
dynamicServiceLayer.Refresh();