Select to view content in your preferred language

Need to get addressabilty to the IApplication object

1139
8
Jump to solution
12-03-2013 12:30 PM
MichaelEber
Deactivated User
I'm working on a server component that is being run and tested in ArcMap as a tool.
The code is running and we are getting results but not expected results.

Part of the process creates a cost array which we want to add to the map.  I have the basics ONCE I HAVE A MAP, but to get the   map I need to create the IApplication object.

So running as a tool without any ESRI templates in my code...how do I create the IApplicationObject for accessing the maps in ArcMap???

Thanks
0 Kudos
1 Solution
8 Replies
NeilClemmons
Honored Contributor
How are you running this code?  Your post says you are testing the component inside of ArcMap, so whatever mechanism you're using to run that code should have access to the application.  For instance, if you've created a command then it is given a reference to the application in its OnCreate method.
0 Kudos
RichardWatson
Deactivated User
You have to run ArcMap to get IApplication.  This implies that your code/DLL will execute within the context of the ArcMap process.

I think that since you are developing a server tool that you should not be using IApplication because that interface is only available in ArcGIS For Desktop applications:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/Overview/00230000010v00...
0 Kudos
MichaelEber
Deactivated User
Neil,

Yes it is a service, however for testing we are running it as a tool inside ArcMap.  Since I am running inside the context of ArcMap can I still get a way to gain access to IApplication?
0 Kudos
NeilClemmons
Honored Contributor
Neil,

Yes it is a service, however for testing we are running it as a tool inside ArcMap.  Since I am running inside the context of ArcMap can I still get a way to gain access to IApplication?


Yes, if you are creating the tool using COM then the hook parameter passed into ICommand.OnCreate is of type IApplication, you just need to cast it and keep up with it.  If you're creating an add-in then there is a global object available that will give you the reference.  I don't use add-ins so I can't tell you what it's called but I'm sure it's in the documentation.
0 Kudos
MichaelEber
Deactivated User
Yes, if you are creating the tool using COM then the hook parameter passed into ICommand.OnCreate is of type IApplication, you just need to cast it and keep up with it.  If you're creating an add-in then there is a global object available that will give you the reference.  I don't use add-ins so I can't tell you what it's called but I'm sure it's in the documentation.


For tools we have a class that defines the parameters, value types, and the IGPEnvironmentManager along with the IGPMessages object.  I think that it would make sense that it is in the IGPEnvironmentManager but I'll have to start search on that to find out.

Thanks.
0 Kudos
MichaelEber
Deactivated User
0 Kudos
RichardWatson
Deactivated User
ArcObjects Library Reference (Framework)
0 Kudos