Hi John, Sorry again for the late reply.. I have been busy with other items, but I also have spent more time on the above issues.
With respect to b);
Here is the code that would sometimes cause the errors in question:
try
{
automationApplication.OpenFile(modelFile);
}
catch (Exception ex)
{
logger.Warn("Unable to generate single NWD from model for: " + modelFile + " " + e.Message);
}That is it. No other code is causing the exceptions + poor error messages. I am simply calling OpenFile() a number of times (1000's) and eventually calling SaveFile or Publish (via the plugin) to save a NWD.
I have discovered that some of the exceptions being thrown by the automation API (with the error message stating: Error calling method: -2147417851 [for example]) can be explained by some missing ObjectEnablers that needed to be installed for Navisworks Manage 2011. After installing these, many, (but not all), of the errors were avoided.
However, when I do come accross a DWG that causes an exception to occur, I notice two things:
1) once I get into the catch block, the roamer.exe process has terminated, thus causing the subsequent calls to OpenFile() to fail (Note that my NavisworksApplication object is still valid (i.e.: not null), but the roamer.exe process is gone.)
2) In the console output I see "A first chance exception of type 'System.InvalidOperationException' occured in Autodesk.Navisworks.Automation.dll
So as a temp workaround, I terminate and reinitialize my reference to the NavisworksApplication object once the exception is caught, (not shown in the above code snippet). This at least allows me to continue on (mostly successfully) with the rest of the models to process.
Now the really puzzling this is that models that failed to open in one run would succeed to be opened in another. For example, modelA.dwg would fail to be opened in a run, but if I launch the run again (processing the same models) modelA.dwg may succeed in being opened.
This leads me to think that perhaps some other intermittent thing is at play here. I have tried copying and processing the models locally, but I still have the bizzarre results.
Could this be a license thing? I am accessing a license server, and there are 100's of licenses available. Perhaps a license is trying to be grabbed at every OpenFile operation and this occurs too quickly??? Or does a a license only get grabbed when the roamer.exe process is started?
I'm grasping here.. but this issue is really killing me.
What are some other causes of the InvalidOperation exception being thrown by the Automation API, (keeping in mind that sometimes it works fine, sometimes it fails.)
As for C) - this issue is not nearly as critical to solve as B is for me. But to answer your question, ANY application that has focus (for example, Notepad) will loose it once myApp calls AnyMethodInNavisworksAutomationApi(). Running any application that uses the automation API and watching / monitoring which application window has focus will indicate this.