代码之家  ›  专栏  ›  技术社区  ›  Liudi Wijaya

无法强制转换“CrystalDecisions”类型的COM对象。ReportAppServer。控制器。ReportSourceClass'

  •  14
  • Liudi Wijaya  · 技术社区  · 7 年前

    我有两个windows程序。

    程序A:使用visual studio 2015和crystal report SP18创建

    程序B:使用visual studio 2017和crystal report SP22创建

    我有一台带有crystal report runtime SP 18的计算机。

    我在那台计算机上运行程序A。程序A可以创建报告。我在那台计算机上运行程序B。程序B无法创建报告。因此,我将crystal report运行时升级到SP22。结果是程序B可以创建报告。

    现在的问题是程序A在升级后无法创建报告。错误是:

    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)
    

    我该怎么办?降级Crystal report runtime还是什么?

    3 回复  |  直到 7 年前
        1
  •  31
  •   Liudi Wijaya    6 年前

    在谷歌搜索了很长时间后,我找到了解决方案。

    解决方案是在应用程序中添加以下代码。配置/web。配置

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

    这是来源 Crystal Reports, Developer for Visual Studio Downloads

    Solution

        2
  •  1
  •   Muhammad Imran Hussain Khan    5 年前

    只需删除crystal reports的旧引用并添加新程序集。这是由于crystal report版本不同,旧编译使用旧版本。

    只需添加当前版本和干净解决方案的新引用程序集,然后重建项目并运行。

    它起作用了。

        3
  •  0
  •   toha    4 年前

    我使用win 10 64位。

    App Server使用64位操作系统。

    对于这个问题,我可以给你一些建议:

    1. IIS应用程序池:已启用32位应用程序
    2. 在我的情况下,另一个团队使用 CR Runtime SP 20。和我的应用程序使用 CR Runtime SP 21 . 我的计算机是64位操作系统,但我安装了CR Runtime SP 21 32位版本,然后解决了此问题(在安装CR Runtime SP21之前,我必须先卸载CR Runtime SP 20)

    案例已解决,我们应该将旧版本的CR升级到新版本(我的案例为SP 21),反之亦然。

    可能您当前的CR运行时是SP 21或更高版本。尝试降级至CR SP 20或以下。