我在使用 WPF 其他其他软件的时候,发现出现Win32Exception异常。
在 MAC 系统下,如果在运行过程中,应用程序的文件被删除了,那么此时如果应用程序执行了 Process.Start 方法时,将会抛出 Win32Exception 异常 我写了一个工具 dotnetCampus.UpdateAllDotNetTools dotnetCampus.UpdateAllDotNetTools 更新 dotnetCampus.UpdateAllDotNetTools 到最新版本之后,其他的 dotnet tool 就都不能更新了,将会抛出 Win32Exception startInfo); if (Directory.Exists(filename)) { throw new Win32Exception 这是一个获取传入的进程号拿到对应的文件路径的方法,如果传入的进程号对应的文件被删除了,那么将会抛出 Win32Exception 异常 System.ComponentModel.Win32Exception
当前实际可用内存量:{result.ullAvailPhys / 1000 / 1000}MB"); Console.ReadKey(); } /// <exception cref="<em>Win32Exception</em> Native.GlobalMemor www.laipuhuo.com yStatusEx(ref memoryStatusEx)) throw new <em>Win32Exception</em>("无法获得内存信息
GetProcessDEPPolicy(hProcess, out var lpFlags, out permanently)) 20 { 21 throw new Win32Exception SetProcessDEPPolicy((int)flag)) 38 { 39 throw new Win32Exception(); 40 file); 31 32 if (hModuleDLL == IntPtr.Zero) 33 { 34 throw new Win32Exception if (pExportedFunction == IntPtr.Zero) 45 { 46 throw new Win32Exception = 0) 58 { 59 throw new Win32Exception(); 60 } 61
LoadLibrary(dllName); if (h == IntPtr.Zero) { Exception e = new Win32Exception Kernel32.LoadLibrary(dllName); if (h.IsInvalid)//是否是无效的 { Exception e = new Win32Exception
SETDTR : CLRDTR)) { throw new Win32Exception(); } } } public bool Rts { set { SETRTS : CLRRTS)) { throw new Win32Exception(); } } } public bool Break { set SETBREAK : CLRBREAK)) { throw new Win32Exception(); } } } public bool Cts { get GetCommModemStatus(m_hFile, out status)) { throw new Win32Exception(); } return (status GetCommModemStatus(m_hFile, out status)) { throw new Win32Exception(); } return (status
即: Process.EnterDebugMode(); //用来开启本进程调试特权(SeDebugPrivilege) 随即把这句放到一个测试程序中,再把测试程序拷到问题电脑上跑,果然是它,抛异常:Win32Exception
我在使用 WPF 其他其他软件的时候,发现出现Win32Exception异常。
堆栈跟踪:[Win32Exception (0x80004005): 拒绝访问。][ExternalException (0x80004005): 无法执行程序。
process.WaitForExit(); } catch (Win32Exception ex) { // 无法结束进程,可能有很多原因
permission If Not NativeMethods.MessageBeep(-1) Then Throw New Win32Exception NativeMethods.MessageBeep(-1)) throw new Win32Exception(); } } internal static class
process.WaitForExit(); } catch (Win32Exception ex) {
try { Console.WriteLine(process.GetCommandLine()); } catch (Win32Exception
permission If Not NativeMethods.MessageBeep(-1) Then Throw New Win32Exception NativeMethods.MessageBeep(-1)) throw new Win32Exception(); } } internal static class
commandLine, out var argc); if (argv == IntPtr.Zero) { throw new Win32Exception
= ERROR_SUCCESS) { throw new Win32Exception((int)result); } { continue; } else { throw new Win32Exception
只不过 .NET 里面的 Win32Exception 仅对通用的 Win32 错误码有用,且可能存在一些中文翻译挖坑问题,而 Microsoft Win32Error 错误查找工具 可以帮助大家从更多头文件找到定义
throw new ServiceNotExistException(); } throw new Win32Exception = 0xEA) //仅当错误值不是大小不够(ERROR_MORE_DATA)时才抛异常 { throw new Win32Exception(); , bytesNeeded, ref bytesNeeded, ref numEnumerated)) { throw new Win32Exception
try { return GetCommandLineArgsCore(); } catch (Win32Exception
NativeMethods.TerminateProcess(handle, -1)) throw new Win32Exception(); NativeMethods.DUPLICATE_CLOSE_SOURCE)) { throw new Win32Exception