Is it possible to work with MapDocuments from a console app?

2891
2
04-17-2013 01:24 PM
SeanNakasone
New Contributor II
Is it possible to work with MapDocuments from a console app.

Here's some example code:

            IMapDocument pMapDocument = new MapDocument();

This is the error I'm getting:

Retrieving the COM class factory for component with CLSID {2FE5E68E-3DA5-4BDA-BAF1-103C55115A1C} failed due to the following error: 80040111 ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE)).

The reason I'm asking is because I've been able to create MapDocument objects from an add-In to ArcMap, but I'd prefer to use a console app that does not depend on an ArcMap session.

This was the code used in the Add-in:

            IMapDocument mapDoc = ArcMap.Document as IMapDocument;
            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;

So my question is, what's the console app equivalent?
0 Kudos
2 Replies
RichardWatson
Frequent Contributor
http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/0012/001200000s1n000000.htm says that the MapDocument class is available in ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.  So, yes this class should work with a Console application.

So, I assume that you have one (or more) of these products installed on the system where your code is running and you have the appropriate license initialization code (something like RuntimeManager::BindLicense).
0 Kudos
SeanNakasone
New Contributor II
Thanks for the info.
I have ArcGIS for desktop standard.
After binding to the Runtime, I can create the MapDocument object.
Ultimately, I'm trying to programatically set symbology for all the layers in the MapDocument.
I tried to find a python solution, but I couldn't find anyway to do it, so I ended up looking at ArcObjects.
0 Kudos