1

I am writing a stand-alone application in c# (using vs2010). I have ArcGis Desktop license.
I only need to insert a new data frame in an mxd file and save this mxd.

I create MxDocument coclass. Then get IMxDocument interface from that. Then i use its "Maps" property which return me IMaps interface. From that I call its method Add() to add a new dataframe.

Code:

Dim pDocClassOut As MxDocumentClas = New MxDocumentClass()
Dim appl As IApplication = TryCast(pDocClassOut.Parent, IApplication)
Dim mxDoc As IMxDocument = TryCast(appl.Document, IMxDocument)
Dim maps As IMaps = CType(mxDoc.Maps, IMaps)
Dim pMap1 As IMap = New MapClass
pMap1.Name = "XYZ"
maps.Add(pMap1)
mxDoc.UpdateContents()
appl.SaveDocument()
appl.SaveAsDocument("E:\DEV EnGIS\Untitled.mxd")
appl.Shutdown()

Why does this simple code not work?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 18, 2013 at 15:20

1 Answer 1

2

If you are using ArcGIS Engine, then according to the help file this interface will not work because it is for desktop only

Have a look at this link:

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IMaps_Interface/00120000097v000000/

If you are developing for desktop then try the create method.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Aug 18, 2013 at 1:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.