Locking my map to fixed extents crashes ArcMap 10 (works fine in 9.3)

Discussion created by mister_nav on Mar 8, 2012
Latest reply on Mar 13, 2012 by mister_nav

Does anyone know why the following code crashes ArcMap v10?
if you attempt to view Data Frame properties after running it - bupbow!

But it works perfect in v9.3.1
also - is there a way of getting around it? I need this functionality to migrate our Production environment to v10.

Many thanks,


        public override void OnClick()
            IApplication application = m_hookHelper.Hook as IApplication;
            IMxDocument mxdDoc = application.Document as IMxDocument;

            IMap map = mxdDoc.ActiveView.FocusMap;
            IGraphicsContainer graphicsContainer = mxdDoc.PageLayout as IGraphicsContainer;
            IFrameElement frameElement = graphicsContainer.FindFrame(map);
            IMapFrame mapFrame = frameElement as IMapFrame;

            // this line crashes in ArcGIS v10
            mapFrame.ExtentType = esriExtentTypeEnum.esriExtentBounds;
            // this line also crashes in ArcGIS v10
            //mapFrame.ExtentType = esriExtentTypeEnum.esriAutoExtentBounds;