Search code examples
winformsvisual-studio-2015crystal-reportsvisual-studio-2017report

Unable to cast COM object of type 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass'


I have 2 windows program.

Program A : create with visual studio 2015 with crystal report SP18

Program B : create with visual studio 2017 with crystal report SP22

I have a computer with crystal report runtime SP 18.

I run program A in that computer. Program A can create report. I run program B in that computer. Program B cannot create report. So, i upgrade the crystal report runtime to SP22. The result is Program B can create report.

Now the problem is Program A cannot create report after the upgrade. The error is :

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.PerintahCetakTT()
   at Portal_Inkaso.frIndex.Perintah1()
   at Portal_Inkaso.frIndex.llbPerintah_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)

What should i do ? Downgrade crystall report runtime or what ?


Solution

  • After googling a long time, i found the solution.

    The solution is add below code in app.config/web.config

    <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>
    

    This is the source Crystal Reports, Developer for Visual Studio Downloads

    Solution