ASP net Report issue

Stimulsoft Reports.NET discussion
rapid
Posts: 9
Joined: Wed Sep 10, 2008 4:33 am
Location: k

ASP net Report issue

Post 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.



Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

ASP net Report issue

Post 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.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

ASP net Report issue

Post by Vital »

Hello,

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

Thank you.
rapid
Posts: 9
Joined: Wed Sep 10, 2008 4:33 am
Location: k

ASP net Report issue

Post 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






















Stephan1
Posts: 122
Joined: Fri Aug 31, 2007 7:22 am
Location: Germany

ASP net Report issue

Post 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

rapid
Posts: 9
Joined: Wed Sep 10, 2008 4:33 am
Location: k

ASP net Report issue

Post 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.







Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

ASP net Report issue

Post 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.
rapid
Posts: 9
Joined: Wed Sep 10, 2008 4:33 am
Location: k

ASP net Report issue

Post 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


Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

ASP net Report issue

Post by Edward »

Hello, Rapid.

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

Thank you.
rapid
Posts: 9
Joined: Wed Sep 10, 2008 4:33 am
Location: k

ASP net Report issue

Post by rapid »

Hi Edward,

Now everything work fine.

Thank you very much.
Post Reply