Derek,
This appears to be due to a small bug in the instrument driver wizard, which would only appear in the case that the underlying driver dll failed to load (which just happens to be the case you're testing for...) The call to the init function in the constructor throws the DllNotFoundException, so you never get a reference back to the created object - but there IS still an object being created. That exception is being caught by your program. The uncaught exception, coming from Dispose, is occuring at the end the program when the garbage collector goes through to dispose everything in memory. The exception thrown from the constructor leaves the niFgen object in a bad state, where it has no session handle, but thinks it has not been disposed
yet. The solution is, in your niFgen.cs file, modify the
definition for the _disposed field to read:
"private bool _disposed = true," and then modify the constructors to include a final line that says "_disposed = false;" I am attaching a fixed version of the niFgen.cs file which includes these changes. We will add this to our bug list for the next version of the instrument driver wizard as well.