fix P/invoke try-catch