HRESULT 异常
是否有任何解释错误代码的列表。 Eks:HRESULT:0x81070215 没有告诉我任何错误时发生了什么?
Is there any lists where the error codes are explained. Eks: HRESULT: 0x81070215 does not tell me enything about what when wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我的计算机上有以下路径,您的计算机也将类似:
顺便说一句,如果您安装了 Visual Studio,则有一个名为“错误查找”的可用工具。转到 Visual Studio,工具 -> 错误查找,您可以在其中输入任何 HRESULT 代码来获取其描述。您也可以从此位置下载ErrorLookup。
I have this at the following path on my machine, yours will be similar as well:
BTW, if you have Visual Studio installed, then there is a tool available named 'Error Lookup'. Go to Visual Studio, Tools->Error Lookup and in it you can put any HRESULT code to get it's description. You can download ErrorLookup from this location as well.
HRESULT
代码是由导致它们发生的代码定义的,因此没有唯一的列表 - 它取决于服务器代码的含义。通常,您需要查看当前线程的错误信息 ,并查看随其传递的附加信息,以便使其有意义。The
HRESULT
codes are defined by the code that is causing them to happen, so there is no unique list - it depends on the server code as to what they mean. Normally, you want to look at the error info for the current thread, and see what additional information is passed along with it, in order for it to make sense.VS的工具菜单中有一个错误查找工具(
Tools->Error Lookup
),你也可以在这里找到工具There is an error look tool in VS's Tools menu (
Tools->Error Lookup
), also you can find tool here一些更常见的错误消息可以通过 Windows 内置工具(如
certutil
或net
)查找,因为问题被标记为
.net
:也是元帅。 GetExceptionForHR 可用于将一些 HRESULTS 转换为有用的 .net 异常。也可以从 Powershell 调用:
PS C:\> [System.Runtime.InteropServices.Marshal]::GetExceptionForHR(0x81070215, -1)
遗憾的是,此方法也没有为请求的值
0x81070215
提供任何有用的信息。微软提供了一个很长的通用值列表,名为 pdf,名称为 MS-ERREF。此列表也不包含请求的错误。
我们可以从描述中看到HRESULT 结构的 ,该值设置了
S
位(这是一个错误),清除了C
位(Microsoft 定义的,而不是客户定义的) )、N
位清除(不是包装的 NTSTATUS)、Facility
0x107 和Code
0x215。设施代码 0x107 是FACILITY_DEPLOYMENT_SERVICES_PXE
。 部署服务
wdspxe.h< 中的函数文档/code> 标头
(我根据名称猜想它主要对应于该设施)列出了
WdsPxe.dll
作为相应的库。如果您的系统上有该库,您可以尝试使用FormatMessage
,如此答案中所述并将句柄传递给WdsPxe.dll
而不是该 anwser 中使用的ntdll.dll
。Some of the more common error messages can be looked up via windows built in tools like
certutil
ornet
As the question is tagged
.net
: There is also Marshal.GetExceptionForHR which can be used to translate some HRESULTS into useful .net exceptions.It can also be called from Powershell:
PS C:\> [System.Runtime.InteropServices.Marshal]::GetExceptionForHR(0x81070215, -1)
Sadly this method also doesn't provide anything useful for the requested value
0x81070215
.A quite long list of common values is available from microsoft as pdf under the name MS-ERREF. This list also doesn't include the requested error.
We can see from the descripton of the HRESULT structure, that the value has the
S
bit set (it is an error),C
bit clear (Microsoft-defined, not customer-defined),N
bit clear (not a wrapped NTSTATUS),Facility
0x107 andCode
0x215. Facility code 0x107 isFACILITY_DEPLOYMENT_SERVICES_PXE
. The documentation of functions in the Deployment Serviceswdspxe.h
header (which I guess based on the name would be what mostly corresponds to that facility) listsWdsPxe.dll
as the corresponding library. If you have that library on your system you could try to useFormatMessage
as described in this answer and pass in a handle toWdsPxe.dll
instead ofntdll.dll
which is used in that anwser.