我在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错误?