我试图将图像作为参数传递给RDLC报告中的图像。我尝试使用以下内容:使用资源图像作为RDLC中的值参数
string imgPath = new Uri("pack://application:,,,/Resources/default_product_img.png").AbsoluteUri;
string imgPath = new Uri(AppDomain.CurrentDomain.BaseDirectory + "pack://application:,,,/Resources/default_product_img.png").AbsoluteUri;
string imgPath = new Uri("/Resources/default_product_img.png").AbsoluteUri;
string imgPath = new Uri(AppDomain.CurrentDomain.BaseDirectory + "/Resources/default_product_img.png").AbsoluteUri;
string imgPath = new Uri("pack://application:,,,/Resources/default_product_img.png", UriKind.Absolute).AbsoluteUri;
string imgPath = new Uri(HttpContext.Current.Server.MapPath("~/Resources/default_product_img.png")).AbsoluteUri;
string imgPath = new Uri(HostingEnvironment.MapPath("~/Resources/default_product_img.png")).AbsoluteUri;
但是当我运行它时,显示屏总是显示红色的X.我设法做到了这一点,但图像的来源与.exe
处于同一水平,而不在其中。
我也试过创建一个BitmapImage
,但ReportParameter()
只接受字符串。
有没有办法让这个工作?或者我应该将它复制到.exe
文件旁边?
注意事项:
图像源设置为
External
default_product_img.png
里面Resources
文件夹,并具有Build Action
Resource
的参数名称设置作为值在
Use this image:
使用内嵌在exe文件中的图像时外部无效? – Swellar
我错过了关于它是嵌入式资源的部分。我建议然后使用数据库选项并将其读入位图对象(在我的答案中的第一个建议之后)。 – David