问题描述
我有2个Windows程序。
程序A:使用Visual Studio 2015创建带有水晶报表SP18
程序B:使用Visual Studio 2017创建带有Crystal Report SP22的计算机
我有一台带有Crystal Report运行时SP 18的计算机。
我在那台计算机上运行程序A。程序A可以创建报告。我在那台计算机上运行程序B。程序B无法创建报告。因此,我将Crystal Report运行时升级到SP22。结果是程序B可以创建报告。
现在问题是程序A升级后无法创建报告。错误是:
System.InvalidCastException:无法将类型为 CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass的COM对象转换为接口键入 CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource。此操作失败是因为由于以下错误而导致IID为'{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}'的接口的COM组件上的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE)) 。 System.StubHelpers.StubHelpers.GetCOMIPFromRCW的
(Object objSrc,IntPtr pCPCMD,IntPtr& ppTarget,Boolean& pfNeedsRelease)
(CrystalDecisions.ReportAppServer.Controllers.ReportSourceClasss.Refresh()$ b.b) CrystalDecisions.CrystalReports.Engine.FormatEngine.Refresh(RequestContext reqContext)的ReportSource.EromReportSourceBase.Refresh(RequestContext reqContext)
CrystalDecisions.CrystalReports.Engine.ReportDocument.Refresh()
at CrystalDecisions。 CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val,Type type)
在CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val,Type type)在CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource( DataTable dataTable)Portal_Inkaso.frIndex.PerintahCetakTT()
Portal_Inkaso.frIndex.Perintah1(b)
Portal_Inkaso.frIndex.llbPerintah_LinkClicked(Object sender,LinkLabelLinkClickedEventArgs e)
b在System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e)
在System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e)
在System.Windows.Forms.Control.WmMouseUp(Message& m,MouseButtons按钮,Int32单击)System.Windows.Forms.Control.WndProc(Message& m)
System.Windows.Forms.Label.WndProc(Message&m)
在System.Windows.Forms.LinkLabel.WndProc(Message& msg)
在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)
在System.Windows.Forms.Control.ControlNativeWindow .WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)
我该怎么办?降级Crystall报表运行时或什么?
长时间搜索后,我找到了解决方案。
解决方案是在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>
这是来源
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 ?
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
这篇关于无法转换类型为'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass'的COM对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!