Are these calls equivalent?
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
throw new Win32Exception();
They are not equivalent.
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error())
throws a COM exception. This could be System.Runtime.InteropServices.COMException
or an exception appropriate to the Win32 error code.throw new Win32Exception()
throws a Win32 exception, System.ComponentModel.Win32Exception
.