I am trying to use ArcFM with my ArcGIS project, and I’ve noticed a bug.
If my main thread is marked with the [STAThread] attribute, the program hangs on exit with the OS Loader Lock exception. When I remove that attribute the program ends just fine.
The following code hangs
[STAThread]
private static void Main()
{
MMAppInitialize mmAppInitialize = new MMAppInitialize();
mmAppInitialize.IsProductCodeAvailable(mmLicensedProductCode.mmLPDesigner);
}
Anyone here have seen it before? Is there something I am doing wrong?
I figured I have to run on STAThread, since otherwise all my COM invocations will be marshalled to a different thread from the main.
Found my bug –
This will work fine:
There is still a small bug –
This doesn’t work:
Though this is not a real usecase – just checking for a license, without getting it.
In my “real” code I was calling the
Initializeand finallyShutdown, but I got the LoaderLock exception because I was shutting down the mmAppInitialize after the aoAppInitialize. After switching the order, the program terminated properly.