I have a .NET 2.0 program that has a reference to Interop.WIA.dll (.NET), which requires the library wiaaut.dll to be registered in the system.
If my program is run in an OS where wiaaut.dll is not registered (shuch as a fresh Windows XP install) the program crashes at startup.
I have enclosed all the code in the main in a try / catch block, but no exception is thrown. Is there a way I can handle this?
If your main method, or static fields in the class containing your main method, reference types from the missing DLL, an exception will be thrown during JITting, before any code in your main method executes.
The best solution is to move all references to the DLL in question to a different class. In this way, the reference is not needed to JIT your main method, and your try/catch will work.
Something like: