private static void HandleError()
{
int lastError = Marshal.GetLastWin32Error();
switch (lastError)
{
case Interop.Errors.ERROR_INVALID_HANDLE:
case Interop.Errors.ERROR_PARTIAL_COPY:
// It's possible that another thread caused this module to become
// unloaded (e.g FreeLibrary was called on the module). Ignore it and
// move on.
break;
default:
throw new Win32Exception(lastError);
}
}