Select to view content in your preferred language

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

530
1
03-08-2012 12:24 PM
NavinSushil
Deactivated User
Hello,

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,

-nav.

        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;
        }
0 Kudos
1 Reply
NavinSushil
Deactivated User
So, there was some code leading up to the original snippet that was the actual cause of problem.

I originally had:
            (m_frame.Map as IActiveView).Extent = extent;

which I changed to the following and it's not crashing anymore:
            (m_frame.Map as IActiveView).Extent = extent;
            m_frame.MapBounds = extent;


Thanks to Walter at support for picking this up.

-nav.
0 Kudos