Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a new map frame in the PageLayout Control. But I got the error: Error HRESULT E_FAIL has been returned from a call to a COM component at the method AddElement.

Please see below codes:

                    IEnvelope envelope = new EnvelopeClass();
                    envelope.PutCoords(Upper_LeftX, Upper_LeftY - _Height, Upper_LeftX + _Width,

                    IMap map = new MapClass();

                    IMapFrame mapFrame = new MapFrameClass();
                    mapFrame.Map = map;
                    IElement mapElement = mapFrame as IElement;
                    mapElement.Geometry = envelope;

                    pageControl.ActiveView.GraphicsContainer.AddElement(mapElement  , 0); // throw error
                    pageControl.ActiveView.FocusMap = mapFrame.Map;
                    pageControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

Do you know why ?

Thanks and regards,


share|improve this question
The above error only happen when the pageControl.ActiveView.FocusMap (MapFrame) is being selected – taibc Nov 6 '12 at 9:49
Are there anyone know how to fix it ? – taibc Nov 8 '12 at 3:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.