windows-8 - 给定的System.Uri无法转换为Windows.Foundation.Uri

标签 windows-8 windows-runtime

我正在尝试以编程方式在XAML Metro应用程序中加载BitmapImage。这是我的代码:

var uri = new Uri("/Images/800x600/BackgroundTile.bmp", UriKind.RelativeOrAbsolute);
var imageSource = new BitmapImage(uri);

第二行崩溃,出现System.ArgumentException:

The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details.



该链接仅转到MSDN主页,因此没有用。

我还尝试过删除开头的/,以防WinRT对相对URI有不同的期望,但是我仍然遇到相同的异常。

为什么对于似乎完全有效的URI却收到此异常?

最佳答案

在使用者预览中,正确的URL格式显然已更改为ms-appx:/Images/800x600/BackgroundTile.bmp

关于windows-8 - 给定的System.Uri无法转换为Windows.Foundation.Uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7569720/

相关文章:

c# - Windows Phone 8.1 中的警报代码

c# - 如何检查 Windows 设备是手机还是平板电脑/个人电脑?

windows-runtime - 带有 .resx 资源的 Windows Phone 8.1 上的 MissingManifestResourceException

c# - 从 View 模型调用 UIElement 函数

sockets - 无法在 Windows 8 Metro 风格应用程序中使用 IPAddress 或类似类型

windows-8 - 在 Visual Studio 2015 中构建 Windows 8 商店应用程序

javascript - WinRT Metro 风格的 HTML5/JavaScript 应用程序是如何打包和保护的

c# - 在 XAML/C# 中使用多个字体文件定义自定义 FontFamily

xaml - 通过更改 x :uid? 在 VisualStateManager 中进行本地化

c# - 如何在 WinRT 中枚举颜色?