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