locked
Crystal Reports and Visual Studio when deploying RRS feed

  • Question

  • User-1456709951 posted

    Hello,

     

    I´ve been searching for this problem for a while with no luck. I've already tried many things.

     

    The thing is that I'm not able to make work any report when deploying (Windows Server 2012). Everything works fine when I try on my local machine.

     

    I have Visual Studio 2012 and I've installed CRforVS_13_0_8.

     

    This is my code:

     

                ReportDocument myCrystalReport;

                myCrystalReport = new ReportDocument();

                myCrystalReport.Load(Server.MapPath("~/Reports/report2.rpt"));

                CrystalReportViewer1.ReportSource = myCrystalReport;

                CrystalReportViewer1.RefreshReport();

     

     

    I've pasted the error below:

     

    Server Error in '/' Application.


    Access is denied.

    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: Access is denied.

    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: 

    [COMException (0x80004005): Access is denied.]
       CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +90
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +259
    
    [CrystalReportsException: No se ha podido cargar el informe.]
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +322
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +851
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +78
       MMN.Reports.prueba1.Page_Load(Object sender, EventArgs e) +97
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
       System.Web.UI.Control.OnLoad(EventArgs e) +92
       System.Web.UI.Control.LoadRecursive() +54
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

     

    I'd really appreciate any help. 

     

    Many thanks.

    Thursday, April 3, 2014 3:57 PM

Answers

  • User1208776063 posted

    Right click the Microsoft.ReportViewer.Common reference in solution explorer and set copyLocal=true. This will make sure that this dll is copied when the project is built succesfully. If this resolves your error, ideal thing to do would be finding out why it is missing on the web server.  If you do not want to opt for this trial-and-error approach, try installing Microsoft Report Viewer runtime on the webserver.

    But, version number is 11.0.3412.0. So, you have to make sure that you install this one on your local machine as well and update the reference to the latest one.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 3, 2014 4:42 PM

All replies

  • User-183147428 posted

    You for sure have Crystal Reports installed on your web server? If so, is it possible that the account your app is using doesn't have the correct permissions to the folder on your web server where the report is stored?

    Thursday, April 3, 2014 4:13 PM
  • User1208776063 posted

    [COMException (0x80004005): Access is denied.]

    Error message suggests that there is some read/write access issue. Did you give IIS_IUSRS read access to the reports folder?

    Thursday, April 3, 2014 4:20 PM
  • User-1456709951 posted

    Thanks a lot for your replies.

    • I've set full control privileges for
      • C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
      • C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files.
      • The report folder.
    • I've installed on the server:
      • Crystal Report Viewer 13.
      • CRforVS_13_0_8
      • CRforVS_redist_install_64bit_13_0_8
    • My web.config looks like this:

     

    I see this error now after update the web.config:

     

    <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <system.web>
    	<customErrors mode="Off"/>
        <globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" culture="es-ES" uiCulture="es-ES" />
        <compilation debug="true" targetFramework="4.5">
          <assemblies>
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    		<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
            <add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
            <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>        
            <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
          </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5"/>
        <authentication mode="Forms">
          <forms loginUrl="~/account/Login.aspx" name="lamasin.ASPNETAUTH" protection="All" path="/" cookieless="UseCookies" defaultUrl="/Pages/Escritorio.aspx"/>
        </authentication>
        <membership>
          <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="lamasinConn" enablePasswordRetrieval="true" enablePasswordReset="true" passwordFormat="Encrypted" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
          </providers>
        </membership>
        <machineKey decryptionKey="042F8962A94628B5CF7B56F2D58032540438C1E33F980F14" validation="SHA1" validationKey="D375CFAB0A194C34E929F1D69B16E01FEF712C848A13650BE08190861DC2FFB6BAE8E8AEB27108C73EB2B452C981E0913BAC17DA2B7AC98728AC754859D4FC25"/>
        <profile inherits="lamasin.Clases.Users.UserProfile">
          <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="lamasinConn"/>
          </providers>
        </profile>
        <roleManager enabled="true">
          <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="lamasinConn" applicationName="/"/>
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
          </providers>
        </roleManager>
      </system.web>
      <appSettings>
        <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
    	<add key="ResourceUri" value="~/crystalreportviewers13" />
      </appSettings>
      <connectionStrings>    
        <add name="lamasinConn" connectionString="Data Source=localhost;Initial Catalog=lamasin;User Id=lamasinuser;Password=Ysoi4#38" />
      </connectionStrings>
      <system.webServer>
        <handlers>
          <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        </handlers>
      </system.webServer>
    </configuration>

    Server Error in '/' Application.


    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

    Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

    Source Error: 

    Line 14:         <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    Line 15: 		<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
    Line 16:         <add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
    Line 17:         <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    Line 18:         <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>


    Source File: C:\Inetpub\vhosts\mmn.com\httpdocs\web.config    Line: 16 

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' could not be loaded.

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

     

     

    Thanks for helping.

    Thursday, April 3, 2014 4:36 PM
  • User1208776063 posted

    Right click the Microsoft.ReportViewer.Common reference in solution explorer and set copyLocal=true. This will make sure that this dll is copied when the project is built succesfully. If this resolves your error, ideal thing to do would be finding out why it is missing on the web server.  If you do not want to opt for this trial-and-error approach, try installing Microsoft Report Viewer runtime on the webserver.

    But, version number is 11.0.3412.0. So, you have to make sure that you install this one on your local machine as well and update the reference to the latest one.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 3, 2014 4:42 PM
  • User-1456709951 posted

    • Microsoft Report Viewer Runtime installed after downloading it from your link.
    • Solved the problem with the web.config making copyLocal= true (I though the dll was already copied... silly me).
    • The real problem still there:

    Server Error in '/' Application.


    Unknown error 0x80040200

    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: Unknown error 0x80040200

    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: 

    [COMException (0x80004005): Unknown error 0x80040200]
       CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +90
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +259
    
    [CrystalReportsException: No se ha podido cargar el informe.]
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +322
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +851
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +78
       MMN.Reports.prueba1.Page_Load(Object sender, EventArgs e) +97
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
       System.Web.UI.Control.OnLoad(EventArgs e) +92
       System.Web.UI.Control.LoadRecursive() +54
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

    Any idea?

    Thank you!

    Thursday, April 3, 2014 4:57 PM
  • User1208776063 posted

    [COMException (0x80004005): Unknown error 0x80040200] CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0

    It is advisable to dispose COM resources after binding report viewer. Try loading reportviewer this way

    using (ReportDocument reportDocument = new ReportDocument())
    {
        reportDocument.Load(Server.MapPath("~/Reports/report2.rpt"));
        CrystalReportViewer1.ReportSource = reportDocument;
        CrystalReportViewer1.RefreshReport();
        reportDocument.Close();
    }	

    Then, recycle application pool and open the website again.

    Thursday, April 3, 2014 5:07 PM
  • User-1456709951 posted

    That code throws a Null Object Reference Exception in local an throws the same error on the server

    Thursday, April 3, 2014 5:18 PM