FileNotFoundException occured while assign DataSource in CrystalReport

这一生的挚爱 提交于 2019-12-10 19:11:25

问题


System.IO.FileNotFoundException execption thrown while assigning data source in report. I am using visual studio 2013, C# 4.5, WinForm application. I have installed crystal report for visual studio 13.

This is code

    DataSet ds = new DataSet();
    ds.Tables.Add(new DataTable("administration_CashDeskManager_Reports_ReportDataBusinessObject"));
    ds.Tables.Add(new DataTable("administration_CashDeskManager_Reports_ReportDataDetailBusinessObject"));

    Reports.CrystalReport.rptCashDeskTransactionLog Report = new Reports.CrystalReport.rptCashDeskTransactionLog();
    Report.SetDataSource(ds);
    crViewer.ReportSource = Report;

Error thrown on Report.SetDataSource(ds) command.

I think this error is version specific error.

Exception detail :

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.


回答1:


Try again after adding below section in your config:

<startup uselegacyv2runtimeactivationpolicy="true">
  <supportedruntime version="v4.0" />
</startup>



回答2:


Use following code in App.Config File:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup></p>


来源:https://stackoverflow.com/questions/23774260/filenotfoundexception-occured-while-assign-datasource-in-crystalreport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!