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



Crystal Report Hosting:: How to Integrate Crystal Report in ASP.NET MVC 4.0

clock May 14, 2014 08:20 by author Ben

Crystal Reports has been the king of the reporting hill for some time. It offers the most powerful features of any report writer. And ASP.NET MVC 4.0 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.In this article I will give tutorial how to integrate Crystal Report in ASP.NET MVC 4.0.

Prerequisite:

  • .Net framework 4.0
  • Entity Framework
  • Sql Server 2008


Just follow the steps and get result easily:
Step 1 - Create New Project
Go to File > New > Project > Select asp.net mvc4 web application > Entry Application Name > Click OK.

Step 2 - Add a Database.
Go to Solution Explorer > Right Click on App_Data folder > Add > New item > Select SQL Server Database Under Data > Enter Database name > Add.

Step 3 - Create table and insert data for show in report
Open Database > Right Click on Table > Add New Table > Add Columns > Save > Enter table name > Ok.

Step 4 - Add Entity Data Model.
Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select ADO.net Entity Data Model under data > Enter model name > Add.
A popup window will come (Entity Data Model Wizard) > Select Generate from database > Next >
Chose your data connection > select your database > next > Select tables > enter Model Namespace > Finish.

Step 5 Add Action for populate data.
Go To Controller > Add your action > write following code and Rebuild your application to get data from Database.
public ActionResult ReportsEverest()
{
List<everest> allEverest = new List<everest>();
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
allEverest = dc.Everests.ToList();
}
return View(allEverest);
}
</everest></everest>


Step 6 - Add View for show data on page.
Right Click on your Action > Add View > Enter View name > Check Create a strongly-type view > Select your model class > Select Scaffold templete > Select list > Add.

Run Your Application. And look the result,show in your browser.
Here I have added below line for Get Exported PDF File.
<a href="@Url.Action("ExportReport")"> Get Report in PDF</a>

Step 7 - Add Report file(.rpt) and Design your report.
Add "Reports" folder to your project
Right Click on "Reports" folder > Add > New item > Select Report under Reporing (Crystal Report file) > Enter report file name > Add.
Right Click On "Database Fields" under Fields Explorer > Database Expert > Project Data > .NET Objects > Select your Object > Click on simble ">>" > Ok.
Now Design your Report looks.


Step 8 - Add Action for generate PDF File for Report Data
Go To Controller > Add your action > write following code and Rebuild your application to get data from Database.

public ActionResult ExportReport()

        {

            List<everest> allEverest = new List<everest>();

            using (MyDatabaseEntities dc = new MyDatabaseEntities())

            {

                allEverest = dc.Everests.ToList();

            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "rpt_EverestList.rpt"));

            rd.SetDataSource(allEverest);

            Response.Buffer = false;

            Response.ClearContent();

            Response.ClearHeaders();

            try

            {

                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

                stream.Seek(0, SeekOrigin.Begin);

                return File(stream, "application/pdf", "EverestList.pdf");

            }

            catch (Exception ex)

            {

                throw;

            }

        }

Step 10 - Run ApplicationClick on links "Get Report in PDF" and get your report in PDF format.

Best Crystal Reports Hosting with ASPHostPortal.com

ASPHostPortal.com provides you with the technology to drive business performance with advanced reports generation capabilities of the Crystal Reports Hosting. The interactive reports generated by the software maximizes the reporting power of your business. These reports are delivered via Web, email, Microsoft Office applications or Adobe PDF, or as embedded enterprise applications. The interactive dashboards and simplified charts present the data in crystal clear form. With all these features, hosting with Crystal Reports helps you minimize the IT expenditure.

 



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