public static Exception ImaqdxError(int error) { Debug.Assert(error < 0); string message; try { int status = NiImaqdxDll.IMAQdxGetErrorStringCW(error, out message); if (status < 0) { message = String.Format(CultureInfo.InvariantCulture, "Unable to get error message from driver."); } } catch (Exception) { message = String.Format(CultureInfo.InvariantCulture, "Unable to get error message from driver."); } return(Trace(new ImaqdxException(message, (ImaqdxError)error))); }