Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows runtime StreamSocketListener和;向认为无效参数是致命参数的函数传递了无效参数;错误_Windows Runtime_C++ Cx - Fatal编程技术网

Windows runtime StreamSocketListener和;向认为无效参数是致命参数的函数传递了无效参数;错误

Windows runtime StreamSocketListener和;向认为无效参数是致命参数的函数传递了无效参数;错误,windows-runtime,c++-cx,Windows Runtime,C++ Cx,我在Visual Studio中有一个最简单的WinRt c++/cx模板项目,其中我只修改了MainPage构造函数中的三行,并添加了如下简单事件处理程序: MainPage::MainPage() { InitializeComponent(); auto listener = ref new Windows::Networking::Sockets::StreamSocketListener; listener->ConnectionReceived += r

我在Visual Studio中有一个最简单的WinRt c++/cx模板项目,其中我只修改了MainPage构造函数中的三行,并添加了如下简单事件处理程序:

MainPage::MainPage()
{
    InitializeComponent();
    auto listener = ref new Windows::Networking::Sockets::StreamSocketListener;
    listener->ConnectionReceived += ref new Windows::Foundation::TypedEventHandler<Windows::Networking::Sockets::StreamSocketListener ^, Windows::Networking::Sockets::StreamSocketListenerConnectionReceivedEventArgs ^>(this, &App3::MainPage::OnConnectionReceived);
    Concurrency::create_task(listener->BindEndpointAsync(ref new Windows::Networking::HostName("127.0.0.1"), "6667")).get();
}


void MainPage::OnConnectionReceived(Windows::Networking::Sockets::StreamSocketListener ^sender, Windows::Networking::Sockets::StreamSocketListenerConnectionReceivedEventArgs ^args)
{
    throw ref new Platform::NotImplementedException();
}
Unhandled exception at 0x0F983C68 (msvcr120d_app.dll) in XXX.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
该项目启用了“Internet(客户端和服务器)”和“专用网络”功能。
所以我的问题是:为什么我会犯这个错误?这是WinRt错误?

不要在UI线程上调用
.get()
。另外请注意,默认情况下,本地环回不适用于UWP(搜索其他SO问题以找到解决方法)。为什么我不能在UI线程上调用
get()
?我知道冻结UI线程是不好的做法,但是这个错误意味着什么?因为如果你这样做,C++ PPL运行时就会抛出。但您可能会更快地遇到另一个问题,因为您无法准确指出错误的来源。未经处理的异常附带一个调用堆栈,以便您知道错误是在哪里引发的。请在您的问题中包含此调用堆栈。现在你应该缩小错误的范围。由于您只添加了3行代码,只需一次删除一行,直到错误消失。这将使你更接近核心问题。