Uwp Windows.System.Launchurisync仅在Windows 10 mobile上引发异常

Uwp Windows.System.Launchurisync仅在Windows 10 mobile上引发异常,uwp,windows-10-mobile,Uwp,Windows 10 Mobile,我正在开发一个UWP应用程序,它同时面向桌面和移动设备。 在应用程序中的某个点上,使用了以下代码 var success = await Windows.System.Launcher.LaunchUriAsync(new Uri(uri), new Windows.System.LauncherOptions { ContentType = mimeType }); 此代码在桌面上正常工作。例如,当URI是图像的URI时(就像我尝试过的这个),照片应用程序启动并显示照片 但是,在移动设备上,

我正在开发一个UWP应用程序,它同时面向桌面和移动设备。 在应用程序中的某个点上,使用了以下代码

var success = await Windows.System.Launcher.LaunchUriAsync(new Uri(uri), new Windows.System.LauncherOptions { ContentType = mimeType });
此代码在桌面上正常工作。例如,当URI是图像的URI时(就像我尝试过的这个),照片应用程序启动并显示照片

但是,在移动设备上,使用完全相同的参数的完全相同的代码会引发异常

消息:未实现该方法或操作

StackTrace:在 Windows.System.LauncherOptions.put_ContentType(字符串值)位于 MyApp.Services.PresentationService.d_u7.MoveNext()

问题似乎在于启动器选项,因为如果我从调用中删除它们,图像将在浏览器中正常打开。(但是这是不可接受的功能,我需要启动相应的应用程序)

据介绍,windows 10和windows 10 mobile在启动同步方法方面应该没有区别。有人知道发生了什么事吗

根据文档,windows 10和windows 10 mobile在Launchurisync方法方面应该没有区别

实际上,
LauncherOptions.ContentType
属性仅在桌面设备上实现,请参见中的备注

重要信息:此属性仅在桌面设备上实现

-

但是,这是不可接受的功能,我需要启动相应的应用程序

目前,没有简单/直接的方法在手机上实现这一点,有一些解决方法,例如:将图像下载到本地文件夹/图片文件夹,打开照片应用程序或在应用程序中显示它们

var options = new Windows.System.LauncherOptions();
var df = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;
if (df == "Windows.Desktop")
{
            options.ContentType = "image/jpeg";
}
else
{
            //Omitted, save network images into Picture folder

            uriToLaunch = "ms-photos:///"; //Launch Photo app
}
var uri = new Uri(uriToLaunch);
// Launch the URI with the content type
var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

顺便说一句,请使用反馈应用提交您的功能请求,这是让MS知道用户/开发人员需要什么的好方法。

在模拟器中调试时,您是否会遇到相同的错误?还有,你在这个设备上运行的是什么版本?谢谢你的回答@Franklin,我完全没有想到。我将保存到临时文件夹,因为我不需要图像来保存。我还提交了功能请求。