DrawImage() System.NullReferenceExpection


11-24-2009, 11:29 PM

Hi all,

I have a problem that when I use DrawImage(), I got "System.NullReferenceExpection" below is the code:

Private Sub Test_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart                             
   Dim fs As FileStream
   Dim x As Single = 1.1F
   Dim y As Single = 1.1F
   Dim width As Single = 1.1F
   Dim height As Single = 1.1F
   Dim drawRect As New RectangleF(x, y, width, height)
   fs = New FileStream(HttpContext.Current.Server.MapPath("../Images/test.PNG"), FileMode.Open, FileAccess.Read)
   Me.CurrentPage.DrawImage(System.Drawing.Image.FromStream(fs), drawRect)
   fs.Close()

End Sub

at Testrpx.Test_ReportStart(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Reports\Testrpx.vb:line 146                                        at DataDynamics.ActiveReports.ActiveReport.-b01()     at DataDynamics.ActiveReports.ActiveReport.-fa2(Boolean bDelayedInit)       at DataDynamics.ActiveReports.ActiveReport.Run(Boolean syncDocument)                                                                                          at TCM.RpxReportGenerator.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Report\RpxReportGenerator.aspx.vb:line 89

Please help!

Re: DrawImage() System.NullReferenceExpection


11-25-2009, 3:16 AM
Hello,

The problem is not with the DrawImage method of ActiveReports.

If you're attempting to use "Server.MapPath" in the code-behind page of the report, you'll need to "Import System.Web.HttpContext" at the beginning of the report class (before declaration) in order for the report to recognize it, and it will need to be preceded by "Current.".

Regards,
Amit
Amit Pal
GrapeCity- DataDynamics