wpf 无效的 URI:无法确定 URI 的格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22576588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invalid URI: The format of the URI could not be determined
提问by Datta
When try to execute it give an error. in my stand alone application
当尝试执行它时会出错。在我的独立应用程序中
hare is my code
野兔是我的代码
var uri = new Uri(@"Earnest_Indieiduals/image/qty15section3.jpg");
qestion15.Source = new BitmapImage(uri);
error Invalid URI: The format of the URI could not be determined.
错误 URI 无效:无法确定 URI 的格式。


回答by Rohit Vats
Use
用
var uri = new Uri(@"image/qty15section3.jpg", UriKind.Relative);
in case code you are trying to execute is written in assembly Earnest_Indieiduals.
如果您尝试执行的代码是在程序集 Earnest_Indieiduals 中编写的。
Also you can use Pack URI's.
您也可以使用Pack URI 的.
var uri = new Uri("pack://application:,,,/image/qty15section3.jpg",
UriKind.Absolute);
回答by NullReferenceException
Use like this
像这样使用
var uri = new Uri("/Earnest_Indieiduals;component/image/qty15section3.jpg", UriKind.Relative);
qestion15.Source = new BitmapImage(uri);
or
或者
var uri = new Uri("pack://application:,,,/image/qty15section3.jpg")
qestion15.Source = new BitmapImage(uri);

