internal static string GetErrorDetailsAndFreeNativeMemory(IntPtr errorHandle) { using (var error = new ErrorInfoSafeHandle(errorHandle)) { GetErrorInfoString(errorHandle, out IntPtr errorHandleString); using (var errorString = new ErrorInfoStringSafeHandle(errorHandleString)) { return(PointerToString(errorHandleString)); } } }
internal static string GetErrorDetailsAndFreeNativeMemory(IntPtr errorHandle) { using (var error = new ErrorInfoSafeHandle(errorHandle)) { GetErrorInfoString(errorHandle, out IntPtr errorHandleString, out IntPtr errorHandleStringSize); using (var errorString = new ErrorInfoStringSafeHandle(errorHandleString, errorHandleStringSize)) { byte[] buffer = new byte[errorHandleStringSize.ToInt32()]; Marshal.Copy(errorHandleString, buffer, 0, buffer.Length); return(Encoding.UTF8.GetString(buffer)); } } }