日度归档:2021-09-26

这是什么意思?由于有一个主机终止处于队列中,因此在操作完成前,调用方指定的等待超时。

原文:What does this mean? The caller specified wait timed out before the operation completed because a host termination is in queued – The Old New Thing (microsoft.com)September 20th, 2021

因此,您的程序正在运行,处理自己的业务,然后它因为异常0x80070bfe崩溃了:“由于有一个主机终止处于队列中,因此在操作完成前,调用方指定的等待超时”。或可能是0x80070bfd :“在操作完成之前,调用方指定的等待超时”。这完全是胡说八道。这是什么意思?我不记得指定了任何超时,我也不知道主机终止是什么。

这意味着当你的应用程序暂停或恢复时,你调用了Core­Application.Create­New­View。

这个特定的错误是在窗口基础结构代码的深处产生的,问题表现为内部超时。内部low-level组件报告操作超时,这就是错误消息提示为超时的原因。

然后,这个错误会一路向上传播到应用程序,而没有人意识到,“嘿,这个错误可能对我将要报告它的人没有意义”。错误消息在最初的时候是有意义的,但是当错误到达应用程序时,错误的原始上下文已经消失了,除非您戴着可以看穿基础结构的有色眼镜,否则消息就没有意义了。

抱歉!

附加聊天:有时会报告错误码0X87B20C08:这个错误码甚至没有相关的文本信息。

=========================

我们使用SDK时,一定要对SDK错误进行处理。因为SDK错误信息相对专业,最终最终用户是看不懂的。

CertUtil程序将可解码Windows错误代码,并可使用多种形式

原文地址:The CertUtil program will decode Windows error codes, and in a variety of formats – The Old New Thing (microsoft.com)September 21st, 2021

前段时间,我注意到The NET HELPMSG command will decode Windows error codes, at least the simple ones.

Stefan Kanthak指出,还有另一个内置程序可以将数字转换为错误消息,它处理的错误数字和格式比NET HELPMSG多得多。

certutil /error 2
certutil /error 0x80070002
certutil /error -2147024894
certutil /error 2147942402
certutil /error -0x7ff8fffe

第一个显示:

0x2 (WIN32: 2 ERROR_FILE_NOT_FOUND) -- 2 (2)
Error message text: The system cannot find the file specified.
CertUtil: -error command completed successfully.

另外几条说的是同样的事情,但错误号不同:

0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND) -- 2147942402 (-2147024894)
Error message text: The system cannot find the file specified.
CertUtil: -error command completed successfully.

在c++ /WinRT中转换UTF-8字符串和UTF-16字符串

原文:Converting between UTF-8 strings and UTF-16 strings in C++/WinRT – The Old New Thing (microsoft.com)September 22nd, 2021

c++ /WinRT提供了一组函数,用于在UTF-8字符串(底层代码使用char表达)和UTF-16字符串(底层代码使用wchar_t)之间进行转换。

to_string函数接受UTF-16编码的std::wstring_view,并将它们转换为UTF-8字符串,表示为std::string。

相反,to_hstring函数接受UTF-8编码的std::string_view,并将它们转换为UTF-16字符串,表示为winrt::hstring。

to_string和to_hstring的参数可以是任何可转换为相应的字符串视图类型的参数。属于这个类别的类型包括:

TypeConverts to
std::stringstd::string_view
std::wstringstd::wstring_view
winrt::hstringstd::wstring_view

以后,我们可以好好利用这些转换~