我无法在 Windows Phone 10 中为我的通用 Windows 应用程序获取“文件保存选择器”合同。我在应用清单中添加了“文件保存选择器”和“缓存文件更新器”声明。
它在完整的 Windows 10 计算机(经过测试的 Mail 和 Mobile Word)上运行良好。
当我在运行 WP10 的手机上尝试它时,我得到一个A heap has been corrupted (parameters: 0x77344270)
带有错误代码的本机异常0xc0000374
。堆栈跟踪的任何部分都不会进入我的应用程序。
我的TargetFileRequested
听众:
private async void FileSavePickerUI_TargetFileRequested(
FileSavePickerUI sender,
TargetFileRequestedEventArgs args)
{
var deferral = args.Request.GetDeferral();
var filePath = GetSelectedFilePath();
args.Request.TargetFile = await StorageFile.GetFileFromPathAsync(filePath);
CachedFileUpdater.SetUpdateInformation(
args.Request.TargetFile,
CachedFileListener.CreateContentId(contentId, destination),
ReadActivationMode.NotNeeded,
WriteActivationMode.AfterWrite,
CachedFileOptions.None);
deferral.Complete();
}
我是压倒一切OnCachedFileUpdaterActivated(CachedFileUpdaterActivatedEventArgs args)
的,但它永远不会被调用(应用程序在此之前崩溃)。
同样,它只在 WP10 中崩溃。Win10 运行良好。
注意:有时它似乎没有崩溃,但更新器方法仍然没有被调用。
我也在这里尝试过这个示例: https ://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/FilePickerContracts
我得到了类似的结果,因为OnCachedFileUpdaterActivated
它只在桌面而不是电话上调用过。