winforms 无法强制转换“CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass”类型的COM对象

2lpgd968  于 2023-10-23  发布在  其他
关注(0)|答案(4)|浏览(119)

我有两个Windows程序。
程序A:使用Visual Studio 2015和Crystal Report SP18创建
程序B:使用Visual Studio 2017和Crystal Report SP22创建
我有一台装有水晶报表运行时SP 18的电脑。
我在那台电脑上运行程序A。程序A可以创建报告。我在那台电脑上运行程序B。程序B无法创建报告。因此,我将水晶报表运行时升级到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)

我该怎么办?降级crystall报告运行时间还是什么?

km0tfn4u

km0tfn4u1#

在Google搜索了很长时间后,我找到了解决方案。
解决方法是在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>

这是源Crystal Reports, Developer for Visual Studio Downloads

mcdcgff0

mcdcgff02#

只需删除旧的水晶报告的引用并添加新的程序集。这是由于crystal report版本差异,旧编译使用旧版本。
只需添加当前版本的新引用程序集和清理解决方案,然后重新构建项目并运行。
有时灵

ggazkfy8

ggazkfy83#

我用的是win10 64位。
应用服务器使用64位操作系统。
对于这个问题,我可以给予你一些建议:

  1. IIS应用程序池:启用32位应用程序
    1.在我的情况下,另一个团队使用CR Runtime SP 20。我的应用程序使用CR Runtime SP 21。我的电脑是64位操作系统,但我安装CR SP21 32位版本,然后这种情况解决(我必须先卸载CR SP20,然后再安装CR SP21)
    案例解决了,我们应该升级旧版本的CR到新版本(SP 21在我的情况下),反之亦然。
    也许你现在的电脑是SP21或以上.尝试降级到CR SP 20或更低。
k5ifujac

k5ifujac4#

https://support.itserver.biz/to-run-crystal-report-on-windows-iis-server/

  • 首先下载并安装运行时,如CRVS2010CR3220_0-10010309创建
  • c:\temp文件夹
  • 给予对c:\Program Files(x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\的读/写权限
  • 在IIS应用程序池中启用32位应用程序
  • 从c:\Windows\assembly\GAC_MSIL复制Crystal Report程序集文件

到应用程序bin文件夹

  • 从使用crystal report查看器控件的web.config和.aspx中删除crystal report版本号以避免版本冲突

相关问题