Page 1 of 2

ASP net Report issue

Posted: Wed Sep 10, 2008 4:45 am
by rapid
Hi,

I have a problem on generating a report using asp. net. An error 'object reference not set to an instance' occur when i run the code.

Code example :

StiReport report = new StiReport();
report.Load("myreport.mrt");
report.RegData("MyDataSet", MyDataSet);

StiWebViewer1.Report = report;


I think the report.load("filename") cause the error, i also try report.load(server.mappath("filename")) but not work.
Any idea ?


Thank you.




ASP net Report issue

Posted: Wed Sep 10, 2008 6:55 am
by Edward
Hello.

Please open that report with Designer.exe from the standard installation of Stimusoft Reports.Net. Is there an error when you would run the report?

Thank you.

ASP net Report issue

Posted: Wed Sep 10, 2008 3:41 pm
by Vital
Hello,

On which error occurs? Can you provide full error stack?

Thank you.

ASP net Report issue

Posted: Thu Sep 11, 2008 12:50 am
by rapid
try execute this url on my browser - http:/localhost/massage3/filename.aspx
massage3 is a virtual directory.


Case 1:
----------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Report As StiReport = New StiReport()
Dim filename As String = "PrintReceipt.mrt"
Report.Load(filename)
Report.Show()
Me.StiWebViewer1.Report = Report
End Sub

Server Error in '/massage3' Application.
--------------------------------------------------------------------------------

Could not find file 'c:\windows\system32\inetsrv\PrintReceipt.mrt'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\PrintReceipt.mrt'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\PrintReceipt.mrt'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +328
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1038
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +57
Stimulsoft.Report.StiReport.Load(String path) +168
PrintReceipt.Page_Load(Object sender, EventArgs e) +38
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436



**********
Case 2:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Report As StiReport = New StiReport()
Dim filename As String = Server.MapPath(("PrintReceipt.mrt"))


Report.Load(filename)
Report.Show()
Me.StiWebViewer1.Report = Report
End Sub


Server Error in '/massage3' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
Stimulsoft.Report.Render.StiPreviewControl.Clear() +26
Stimulsoft.Report.Render.StiPreviewControl.set_Report(StiReport value) +14
Stimulsoft.Report.Render.StiPreviewForm.InitializeComponent() +129
Stimulsoft.Report.Render.StiPreviewForm..ctor(StiReport report) +19
Stimulsoft.Report.StiReport.Show(Form parentForm, IWin32Window win32Window, Boolean dialogForm) +552
Stimulsoft.Report.StiReport.Show() +10
PrintReceipt.Page_Load(Object sender, EventArgs e) +67
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436























ASP net Report issue

Posted: Fri Sep 12, 2008 2:14 am
by Stephan1
Hi,

if i look at your Trace it seems that the Report is not existing at this position
'c:\windows\system32\inetsrv\PrintReceipt.mrt'

Check if it its there. or use another path for the file.

Stephan


ASP net Report issue

Posted: Fri Sep 12, 2008 7:01 am
by rapid
Stephan1 , you are right if it run on windows.

I am trying to create a web report here. My report is located at c:\inetpub\wwwroot\massage\report.mrt
It run well when i preview on vS 2005 , but when i publish on the web it give above error.
Because system cannot locate the report in the virtual directory.

Anyone got the same problem ? or any solution ? please advise.








ASP net Report issue

Posted: Fri Sep 12, 2008 7:25 am
by Edward
Hello.

Please try the following lie of code:

Code: Select all

string path = HttpContext.Current.Server.MapPath(string.Empty)
report.Load(Path.Combine(path, "PrintReceipt.mrt"))
Thank you.

ASP net Report issue

Posted: Mon Sep 22, 2008 2:50 am
by rapid
Hi Edwards,

I try the following code and run/test on VS2005 with no issue.
But when i deploy on the web server, i got the following error.

Anyone got the solution for this web report issue or provide any sample code ?Please help. Thank you.

*************
Code:
-------

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Report As StiReport = New StiReport()
Dim path As String = HttpContext.Current.Server.MapPath(String.Empty)
Dim filename As String = path + "/PrintReceipt.mrt"
Report.Load(filename)
Report.Show()
Me.StiWebViewer1.Report = Report
End Sub


Error:
---------
Server Error in '/massage3' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
Stimulsoft.Report.Render.StiPreviewControl.Clear() +26
Stimulsoft.Report.Render.StiPreviewControl.set_Report(StiReport value) +14
Stimulsoft.Report.Render.StiPreviewForm.InitializeComponent() +129
Stimulsoft.Report.Render.StiPreviewForm..ctor(StiReport report) +19
Stimulsoft.Report.StiReport.Show(Form parentForm, IWin32Window win32Window, Boolean dialogForm) +552
Stimulsoft.Report.StiReport.Show() +10
PrintReceipt.Page_Load(Object sender, EventArgs e) +110
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436



ASP net Report issue

Posted: Mon Sep 22, 2008 3:14 pm
by Edward
Hello, Rapid.

report.Show method is intended only for Windows Forms applications. Please change this command to report.Render(false)

Thank you.

ASP net Report issue

Posted: Tue Sep 23, 2008 2:50 am
by rapid
Hi Edward,

Now everything work fine.

Thank you very much.