C# 设置bitmapimage uri源

C# 设置bitmapimage uri源,c#,wpf,bitmapimage,C#,Wpf,Bitmapimage,我想为添加到我的项目中的图像设置BitmapImage的UriSource BitmapImage b = new BitmapImage(new Uri(@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "5.jpg", UriKind.Absolute)); 那么我需要安装什么软件包呢

我想为添加到我的项目中的图像设置
BitmapImage
UriSource

  BitmapImage b = new BitmapImage(new Uri(@"pack://application:,,,/"
           + Assembly.GetExecutingAssembly().GetName().Name
           + ";component/"
           + "5.jpg", UriKind.Absolute));
那么我需要安装什么软件包呢。。 例外情况


“SystemNotSupported异常”

可能是因为映像中的元数据不正确。 看这个 有关更多信息。

请尝试此选项 希望它能起作用

Uri uri = new Uri(imageRequestUrl, UriKind.Absolute);
BitmapImage bitmapImage = new BitmapImage(uri);

你能给出整个例外的细节吗?您是在应用程序中还是在测试项目的过去进行此操作?是否已将5.jpg文件的构建类型设置为“Resource”?