什么是不对的URI? [英] What is wrong with this URI?

查看:176
本文介绍了什么是不对的URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HEJ

我想在WPF应用程序中加载(嵌入)图像,采用开放的,但我不断收到一个例外。

I am trying to load an (embedded) image in a wpf application, using an Uri but I keep getting an exception.

中的代码是:

new BitmapImage(new Uri("pack://application:,,,,/Icons/m.png"));



(如果它是不明确的,我试图加载从该m.png文件图标文件夹,
已被标记为一个嵌入式的ressource)。

(In case it isn't clear, I am trying to load the m.png file from the Icons folder, which has been marked as an embedded ressource).

和异常是

NotSupportetException (the URI prefix is not recognized)

任何人可以?告诉我是什么URI应该是

Can anybody tell me what the uri should have been?

推荐答案

您可以看一看的这个博客帖子。解决的办法是注册自定义的URI语法分析器,使其认识到的协议:

You may take a look at this blog post. The solution is to register a custom uri parser so that it recognizes the pack protocol:

UriParser.Register(
    new GenericUriParser(GenericUriParserOptions.GenericAuthority), "pack", -1
);

这篇关于什么是不对的URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆