Monday, January 5, 2009

Issues when working with ArcGIS Engine in .NET

1. First, be prepared for the lack of documentation or that on many occasions you’ll be looking for a .NET example and you’ll find a VBA example. Or, if for one reason or another JavaScript is disabled some links in the Help just won’t work.

2. T o get to anything related to the map, scene or globe you first access it via the control itself which will have some interface it supports. For example, to get access to many of the basic interfaces for the globe control you return the globe control’s object reference which is the IGlobeControl interface. From there you can get to other basic interfaces like IBasicMap.

3. All classes have the word Class on the end of them. For example, the point class isn’t just called Point, it’s called PointClass. Example: IPoint point = new PointClass();

4. The Engine runtime must be installed on all client machines in order to run your application or they must have ArcGIS Desktop.

5. Whenever you want to specify a missing argument in VB you could just supply Nothing but with .NET you must create an object of Type.Missing. This is accomplished by first creating the object like this: object missing = Type.Missing and then supplying “missing” as an argument.

6. Many properties and methods have their own .NET implementation. For example, to set the name of a field you use IFieldEdit::Name_2 as opposed to just Name. For some methods the methods is prefixed with “get_”. For example, a point collection’s point is used in this manner: IPointCollection.get_Point(i);

7. There isn’t an equivalent to using GxDialog because Engine doesn’t come with ArcCatalog libraries per se. You need to build your own dialogs for your application. However, when building a simple app there is an Add Data tool that you can use to quickly add data.

8. You can use an ArcGIS Desktop license to run an Engine application. See this article.


9. You can control how you interact with the license manager via the LicenseControl or AoInitializeClass.


10. COM types that are not OLE automation compliant require you to use different classes altogether. For example you can’t use the IEnvelope interface but you can use IEnvelopeGEN interface on the EnvelopClass.


11. Watch out for Singleton objects. If you try to instantiate them more than once you will get an error. See here for a list of all the singletons. Also, if you forget to kill them they will be pinned in memory.

12. To use OLE StdFont and StdPicture you must add Stdole.dll as a reference in your project.


13. When creating a new command or tool you can also get a reference to the basic interfaces via the HookHelper. This is very useful for creating commands and tools that work in Scene, Map and Globe.

14. Lastly, just be aware that although under the hood ArcObjects is basically the same there are some bugs unique to Engine that you will come across.

No comments:

Post a Comment