locked
crystal report load error RRS feed

  • Question

  • User1035497563 posted

    Hi everyone:

     

    I have a web application that will take in user data and go to a sql server database run the query, create a dataset from the query, and then create a report from that data.  On my development machine with VS 2005 running winXP it works fine.  However on the win server 2003 machine it does not.  I am loading the report using the Crystalreport.LOAD(server.mappath.("~/Filename.rpt")).  Like i said it works on my development machine however on the server it gives me this error screen:

     

    <title>Invalid file name.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style>

    Server Error in '/' Application.

    Invalid file name.

    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: Invalid file name.

    Source Error:

    Line 37:     Private Sub ConfigureCrystalReports()
    Line 38:         Dim rptA As ReportDocument = New ReportDocument()
    Line 39:         rptA.Load(Server.MapPath("") & "\FormA.rpt")
    Line 40:         Dim rptds As DataSet = ReportADSXconfig.ReportADataSet(PreviousPage.PatientID, PreviousPage.Doctor, PreviousPage.Start, PreviousPage.EndDte, Page.User.Identity.Name)
    Line 41:         rptA.SetDataSource(rptds)

    Source File: C:\Inetpub\WebSite1\ReportA.aspx.vb    Line: 39

    Stack Trace:

    [COMException (0x800001fb): Invalid file name.]
       CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +87
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +279
    
    [Exception: Load report failed.]
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +341
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +964
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +73
       ReportA.ConfigureCrystalReports() in C:\Inetpub\WebSite1\ReportA.aspx.vb:39
       ReportA.Page_Init(Object sender, EventArgs e) in C:\Inetpub\WebSite1\ReportA.aspx.vb:16
       System.Web.UI.Control.OnInit(EventArgs e) +2072076
       System.Web.UI.Page.OnInit(EventArgs e) +9
       System.Web.UI.Control.InitRecursive(Control namingContainer) +321
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
    



    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

    I would like to know how to fix this error so that it will run on my server.  I have used the merge modules to run this.  could that be the problem do i need to install the crystal reports server on the windows server.  Just wondering if that could be the issue.  thanks for any help you can give 

    Wednesday, November 15, 2006 12:58 PM

All replies

  • User1001868398 posted

    Check the Server.MapPath("")  I am sure is not returning the folder you want or where the file is

    You should do this

    string checkthivalue = Server.MapPath("") + @"\FormA.rpt"; //C#

    rptA.Load(checkthisvalue);

     

    Wednesday, November 15, 2006 3:07 PM
  • User1035497563 posted

    I did check the string that it is returning:

    it points to the directory which holds the report.  c:/inetpub/website/FormA.rpt

    does the @ symbol works for vb? 

    Wednesday, November 15, 2006 3:13 PM
  • User1001868398 posted

    Are you sure that the file is there? c:/inetpub/website/FormA.rpt

    And do you have all properties to load the file? Remember if you are using IIS, maybe is running with a user that does not have properties in the directory website. Can you move it somewhere else to test it?

    You don't need @ in VB is only C# I believe as \ character is an escape character

    Wednesday, November 15, 2006 3:23 PM
  • User1035497563 posted
    how do i check to see what user i have running the app. 
    Wednesday, November 15, 2006 3:29 PM
  • User1001868398 posted
    Go to IIS/Security
    Wednesday, November 15, 2006 3:38 PM
  • User1035497563 posted

    I checked the string that the server.mappath shows it goes to the directory that holds the file it still gives the same error.

    Then i moved the report to another folder on the server. Still gives an error now it say "INvalid Filename" 

    Wednesday, November 15, 2006 3:42 PM
  • User1129912788 posted

    I have a similar error but for a different reason.  To help you, I suggest avoid using files.  If you have a strongly typed Crystal Report, or can make one, this code will render it on the fly and send it to the client without creating a file.

               MemoryStream oStream; // using System.IO
               oStream = (MemoryStream)
               report.ExportToStream(
               CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
               Response.Clear();
               Response.Buffer= true;
               Response.ContentType = "application/pdf";
               Response.BinaryWrite(oStream.ToArray());
               Response.End();

    This works in my development enviornment and doesn't use files.  I have a different problem on my target machine that causes it not to work.  But I haven't given up.  Anyone know why a target machine with the framework and using the code above will give me a Load Report Failure.  I think it's a crystal dll somewhere.  It's a windows 2000 server.

    Friday, November 17, 2006 2:48 PM
  • User2003233792 posted

    Hello!

    I have a same problem. When I checked Server.MapPath ("~ report / crystalreport.rpt"), it returns D:\domains\storemanager.com\reports\crystalreport.rpt. The file still exists. I think the problem is in storemanager.com. because it have a dot. features it should have been misunderstood as storemanager.com file
    How do you solve this problem?
    Thanks!

    Thursday, July 12, 2012 12:25 AM
  • User241982720 posted

    in IIS -> ASP, please enable parent path

    Wednesday, July 18, 2012 12:09 AM