November 21, 2015

Crystal Report not displayed (with Error: bobj is undefined)

Few days back, I encountered a problem with Crystal Reports while hosted in IIS, it was not getting displayed at-all on ASP.Net page. After searching I got fixed with this, here are the 2 steps you might need to follow in case you face the same problem.
  1. Copy aspnet_client\system_web\4_0_30319\crystalreportviewers13 folder to you website's root directory. This would fix the problem in some cases. If not, try also the second point.
  2. There is already defined a section tag <sectionGroup name="crystalReports"> in web.config, here we need to add one more tag for crystal report viewer aso follows:
    <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />
    
    
    Put the above line just below the <sectionGroup name="crystalReports"> line, before the closing </sectionGroup> tag.

    Somewhere in the last part of web.config, you will find a rptBuildProvider tag like this:
    <rptBuildProvider>
       <add embedRptInResource="true" />
    </rptBuildProvider>
    
    Just below  this tag, you have to add new tag for crystal report viewer to define the path from where it could find its required files.
    <crystalReportViewer>
       <add key="ResourceUri" value="/crystalreportviewers13" />
    </crystalReportViewer>
    
    Here we have defined the path as we have put the crystalreportviewers13 directory in the root of our website. Also you can place it some where else (i.e. in nested directories) if you want, so you have to change the path accordingly in ResourceUri key-value.
Now you can view your crystal report.

No comments:

Post a Comment