Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

Crystal Report Hosting :: How to Fix Unable to Cast COM Object of Type ‘ReportSourceClass’ to Interface Type ‘ISCRReportSource’

clock March 20, 2019 08:31 by author Jervis

When creating or printing a report using Crystal Reports, including printing reports to printer or generating reports in Acrobat PDF format, the following error on Crystal Report Windows Forms Viewer may occur and no report is generated or created.

System.InvalidCastException: Unable to cast COM object of type 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' to interface type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Refresh()
   at CrystalDecisions.ReportSource.EromReportSourceBase.Refresh(RequestContext reqContext)
   at CrystalDecisions.CrystalReports.Engine.FormatEngine.Refresh(RequestContext reqContext)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.Refresh()
   at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataTable dataTable)
   at Portal_Inkaso.frIndex.OrderTT()
   at Portal_Inkaso.frIndex.Order1()
   at Portal_Inkaso.frIndex.llbOrder_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e)
   at System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e)
   at System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Label.WndProc(Message& m)
   at System.Windows.Forms.LinkLabel.WndProc(Message& msg)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The error normally happens due to incompatibility between different version of Crystal Report or normally occurs after platform updates.

Thus, to resolve the “Unable to cast COM object of type ‘CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass’ to interface type ‘CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'” issue, make sure to remove all old Crystal Report assemblies from Reference list in all projects. Then add new Crystal Reports assemblies and rebuild the application. If you’re unable to rebuild the app, add the following code in app.config/web.config to make sure <dependentAssembly> workaround as suggested by SAP:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportSource" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>   
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.Web" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.Windows.Forms" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.ClientDoc" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.CommonControls" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.CommonObjectModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.Controllers" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.CubeDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.DataDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.DataSetConversion" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>   
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.ObjectFactory" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.Prompting" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.ReportDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="CrystalDecisions.ReportAppServer.XmlSerialize" publicKeyToken="692fbea5521e1304" culture="neutral"/>
      <bindingRedirect oldVersion="13.0.2000.0" newVersion="13.0.3500.0"/>
    </dependentAssembly>
  </assemblyBinding> 
</runtime>

Replace the values for newVersion and oldVersion accordingly based on your deployment version.

If the Crystal Reports error only happens on some computers, but not on others, make to to update and deploy same versions of Crystal Reports to all workstations.

Best Crystal Report Hosting?

If you are looking for Crystal Report hosting solution, please kindly visit our site at http://www.asphostportal.com 



Crystal Report Hosting :: How to Display Crystal Report with Images Using Typed Dataset

clock February 18, 2019 08:01 by author Jervis

This document focuses on how to display crystal reports with images using typed dataset. While displaying reports instead of querying to database, we can use already filled data tables. This design is based on Crystal Reports for Visual Studio .NET.

Introduction

This BOK explains simple steps on how to create crystal reports using typed dataset. The instances in this document have been illustrated considering “Company” table which stores general data as well Logo images.

Create typed dataset

This is company master table schema which stores company information and company logo images.

Database Table schema:

  

Follow these steps to add typed data set in your report project.

Go to Project, Add, New Item, Data, then Data Set

Once data set is added in your project then drag and drop database table from server explorer.

In this example I have used Company table.

Data Table:

 

Create report and browse data table

  • Instead of using direct table from database we can use data table from typed data set 
  • Dataset is available under Project Data, then ADO.Net DataSets
  • Select the data table from available data source and add to selected tables section.
  • Once data table is added click “Ok” button to map the data table in crystal report.

 Fill data table in typed dataset

  • Fetch the data from database and fill it in the data table in dataset. 
  • This method returns the data set in display report method

public ReportsDS Report_GetReportData()  
{  
    SqlConnection sqlConn = new SqlConnection();  
    sqlConn.ConnectionString = connectionString;  
    ReportsDS ReportDS = new ReportsDS();  
    string CompanyId = CachingHelper.ReadFromCache(Constants.CompanyId);  
    try  
    {  
        DataSet ds = new DataSet();  
        SqlCommand cmd = new SqlCommand();  
        cmd.CommandType = CommandType.Text;  
        cmd.CommandText = "SELECT * FROM Company WHERE Id ='" + CompanyId + "'";  
        cmd.Connection = sqlConn;  
        SqlDataAdapter da = new SqlDataAdapter(cmd);  
        da.Fill(ReportDS, ReportDS.Company.TableName);  
    } catch (Exception ex)   
    {  
        throw;  
    } finally  
    {  
        if (sqlConn.State != ConnectionState.Closed) sqlConn.Close();  
        sqlConn.Dispose();  
    }  
    return ReportDS;  

Display Reports

  • Create instance of Report Document and set DataSource as data table
  • Set ReportSource as Report Document in crystal report viewer
  • Call DisplayReport() method in events like button click.

private void DisplayReport()  
{  
    try  
    {  
        ReportsDs ReportDS = new ReportsDs();  
        ReportDocument obj = new ReportDocument();  
        ReportDS = Report_GetReportData();  
        obj.FileName = “rptCompanyReport.rpt”;  
        obj.SetDataSource((DataTable) ReportDS.Company);  
        crystalReportViewer1.ReportSource = obj;  
        crystalReportViewer1.Refresh();  
    } catch (Exception ex)   
    {  
        Logging.CustomizedException(ref ex, false);  
    }  

Report



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions

 photo ahp banner aspnet-01_zps87l92lcl.png

Author Link

Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in