gpt4 book ai didi

c# - 从 Windows Phone 8.1 运行时组件访问 CoreWindow

转载 作者:行者123 更新时间:2023-11-28 06:14:12 25 4
gpt4 key购买 nike

我正在尝试从 Windows Phone 8.1 C++ 运行时组件访问 CoreWindow。该组件需要对 CoreWindow 触发的一些事件使用react。我有以下代码。

IAsyncAction^ MyClass::RegisterCoreWindowVisibilityChanged()
{
return CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler(
[this]
{
auto eventHandler = ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &MyClass::OnCoreWindowVisibilityChanged);
Window::Current->CoreWindow->VisibilityChanged += eventHandler;
}
));
}

当使用该组件的应用程序是一个通用应用程序时,这工作正常,但在 silverlight 应用程序中失败并出现访问冲突异常。

0xC0000005: Access violation reading location 0x00000000.

显然 Windows::Current 在 silverlight 应用程序中返回 null。有没有一种方法可以让它在 silverlight 和 Windows 商店应用程序中工作?

最佳答案

该对象仅在通用应用程序中可用(如 documented )。

您需要对编译进行条件化或考虑切换到适用于桌面和手机的通用应用程序。

关于c# - 从 Windows Phone 8.1 运行时组件访问 CoreWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30640712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com