How to Handle Third Party Exception in During Exit
Posted on 2009-04-30
I am a contractor working building a large commercial piece of software. Because of limited time and resources I have to rely on third parties from time to time to get things built faster, better or just simply more cheaply than I can do myself. Because of this exact reason I am using a third party TWAIN interface, that was written in .NET.
In this particular piece of software it came with a "trial license" and everything seemed to be working fine. I purchased the software and again, things seemed to be working fine until I logged on to the machine as a non-administrator and my software crashed after the last line of MY code has run. Piecing things down a bit further (using reflector) I found out that the license provider for this component is relies on an internal static LicenseProvider variable which isn't finalized till after my application closes. Interestingly, this variable (on dispose, of course) tries to delete a file on the hard drive which it doesn't have access to and so it crashes (a license file that was stupidly created by the same provider earlier).
My question is - without throwing out a third party component that mostly works is their any way to prevent finalize routines from being called or to catch exceptions that happen while the GC is finalizing objects? I have search google but the most suggestions require access to the code which I don't have. Hopefully someone has an idea to try.
Personally, my best idea to date is loading the third party in its own app domain and unloading the domain once I am finished with it but I don't really know much of what that looks like in code. Any help is appreciated.