How can you tell if you are running in ArcMap, Engine, or Server?

477
1
06-22-2010 01:27 PM
RiverTaig1
Occasional Contributor
I have a labeling extension that I originally wrote for ArcMap (works fine).  I then tested it in ArcGIS Engine (works fine too). Now I need to get it working in an ArcGIS Server context.  But, some functionality will be slightly different in that environment.  How can you tell if you are running in ArcMap, Engine, or Server?

I'm also looking for a bomb-proof way of getting the ActiveView or the FocusMap property in either of the three environments.  Ideas?
0 Kudos
1 Reply
RichardWatson
Frequent Contributor
Get the process name.  ArcMap.exe implies ArcMap.  ArcSOC.exe implies ArcGIS Server.  Anything else implies ArcEngine or a standalone tool.  I think that you can also ask the licensing system what ESRI product is licensed.

I have the same problem in that I have code which needs to execute in multiple ESRI execution contexts.  IMHO, ESRI has not done a very good job of abstracting out execution context.  What you probably need is IMap and how get it is different based on the ESRI execution context.  In ArcMap you start with IApplication, in ArcGIS Server you start with IServerObjectHelper, and in ArcEngine you start with the map control.  What we do is to create a different class based on execution context using an inversion of control type of framework.  You have to roll your own.
0 Kudos