我試圖將圖像作爲參數傳遞給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