Crystal Report in .NET: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++

I created a crystal report in Visual Studio 2010 with .NET framework 4.0 . When I ran the website it threw the error "Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++" with the following detail exception:

CrystalDecisions.Shared.CrystalReportsException was unhandled by user code
  HResult=-2146232832
  Message=Load report failed.
  Source=CrystalDecisions.CrystalReports.Engine
  StackTrace:
       at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod

openMethod, Int16 parentJob)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
       at rptViewer.BuildReport() in D:\nam.le\projects\ARC\trunk\ARC\Reports\rptViewer.aspx.cs:line 25
       at rptViewer.Page_Load(Object sender, EventArgs e) in D:\nam.le\projects\ARC\trunk\ARC

\Reports\rptViewer.aspx.cs:line 16
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at ARC.UIBase.PageBase.OnLoad(EventArgs e) in D:\nam.le\projects\ARC\trunk\ARC\UIBase

\PageBase.cs:line 48
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean

includeStagesAfterAsyncPoint)
  InnerException: System.Runtime.InteropServices.COMException
       HResult=-2147215343
       Message=Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++

stack.
       Source=clientdoc.dll
       ErrorCode=-2147215343
       StackTrace:
            at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath,

Int32 Options)
            at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32

Options)
            at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
       InnerException:


So solution is:
Right click on the rpt file, choose the properties, changed as below:
1. Build Action: "Content"
2. Copy to Output Directory: "Do not copy"
3. Custom Tool and Custom Tool namespace: Empty (just removed the value)

Load rpt file:
            ReportDocument rptDoc = new ReportDocument();
            rptDoc.Load(Server.MapPath("~/Templates/rpt.rpt"));

It works like a charm!

Comments