WebViewProcessControl 初始化崩溃 [英] WebViewProcessControl initialization crash
本文介绍了WebViewProcessControl 初始化崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的 Win32 程序中使用现代"Web 视图 API,但是当我初始化 WebViewControlProcess
时,该程序挂起几秒钟,然后突然退出.>
最小示例
I'm trying to use the "modern" web view API in my Win32 program, but when I initialize WebViewControlProcess
, the program hangs for a couple of seconds, and then suddenly exits.
// cl minimal.cpp /EHsc /std:c++17 /await windowsapp.lib
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Web.UI.Interop.h>
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Web::UI::Interop;
int main(void) {
winrt::init_apartment();
printf("Hello\n");
WebViewControlProcess webviews = WebViewControlProcess();
printf(" world!\n");
}
预期产出
Hello
world!
实际输出
Hello
环境
我使用的是 Windows 10.0.17134 (1803).
Environment
I'm using Windows 10.0.17134 (1803).
推荐答案
原来 WebViewProcessControl 需要你 winrt::init_apartment(apartment_type::single_threaded);
.我不知道为什么它需要一个单线程单元,但它可以工作.
Turns out WebViewProcessControl needs you to winrt::init_apartment(apartment_type::single_threaded);
. I don't know why it needs a single-threaded apartment, but it works.
这篇关于WebViewProcessControl 初始化崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文