Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ello,

I have been having issues with auto logon for crystal report viewer and visual studio.

The following code is im using to auto logon and pass on parm values and this is all inside Page_Load:

C#
pono.Text = Request.QueryString["PONU"];
mrrr.Text = Request.QueryString["MRNU"];


//login so users wont have to enter user/pass all the time
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;

cryRpt.Load("~/reports/MatRecReport-new.rpt");

crConnectionInfo.ServerName = "e40";
crConnectionInfo.DatabaseName = "";
crConnectionInfo.UserID = "user";
crConnectionInfo.Password = "pss";

CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}


And this is the error i get:

Server Error in '/' Application.

Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack. 
  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.Runtime.InteropServices.COMException: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.

Line: cryRpt.Load("~/reports/MatRecReport-new.rpt");


How can i load the report thats in the project folder itself?
Posted

1 solution

From what you have shown the problem will be due to how your path is being resolved.
The ~ character refers to the home directory of the application on your web server, for instance;
HTML
http://localhost:1234


To confirm if your path is valid you can just enter the path to the file in your web browser (with the solution running of course) as follows;
HTML
http://localhost:1234/reports/MatRecReport-new.rpt

If you are prompted to save or open the file your path is correct.

Once your path is correct, you will need to use Server.MapPath as follows;
C#
cryRpt.Load(Server.MapPath("~/reports/MatRecReport-new.rpt"));


Kind Regards
 
Share this answer
 
Comments
r00n3y 28-Jan-16 17:18pm    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900