Initializing ArcObjects in a DLL

03-03-2011 11:02 AM
New Contributor

I am working on a stand-alone program that reads data from various spatial data formats, one of which is ESRI geodatabases.  All of the code that accesses ESRI geodatabases resides in its own DLL.  When the client application needs to read a geodatabase, the DLL will perform the following steps:

1) call IAoInitialize::Initialize() to get a license
2) open the geodatabase workspace
3) read the data
4) close the workspace
5) call IAoInitialize::Shutdown(). 

Over the course of a user's session, Initialize() and Shutdown() are likely to be called several times each (in pairs).  Is this a reasonable approach, or would it be better to ensure that Initialize() and Shutdown() are called exactly one time each?  What are the possible consequences, if any, of calling Initialize() and Shutdown() more than once each.


0 Kudos
1 Reply
New Contributor III
There are some overhead with opening and closing workspace.  You program might take longer to execute depending on how many times you're doing this.  I like to open and close one time and get what I need to memory for further processing.  The same applies to AOInitialize because you're hitting the license server so more overhead.  You can probably tell I am in the camp of doing these only once 🙂
0 Kudos