Loading layer from shape file, setting correct extent

Discussion created by ccposton on Jan 31, 2013
Latest reply on Feb 1, 2013 by MBranscomb-esristaff
I'm using the sample below to add shape files as layers in my map.

When I start with an empty map and try adding a shape file, I see it added to the Legend, but I don't see it in the map. I tried clicking the "Full Extent" button in the Navigation control, but I'm getting a NullReferenceException when I do that.

I also tried setting the map's extent to the layer's extent when the Initialized event is fired:

MyMap.Extent = arcGisLocalDynamicMapServiceLayer.FullExtent;

And I also get a NullReferenceException when I do this. What is the proper way to position the map so that I can view the layer?