9

I am having trouble in VS 2010 sap crystalreports, using c# to make a windows application.

I get the following error with the following code:

 CrystalReport1 cr1 = new CrystalReport1();
 cr1.SetDataSource(dt1); //Error 
Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.
Drise
  • 4,310
  • 5
  • 41
  • 66
Rajesh Abraham
  • 203
  • 1
  • 3
  • 10

3 Answers3

18

Try using this solution by adding the useLegacyV2RuntimeActivationPolicy attribute to your .config file

<startup useLegacyV2RuntimeActivationPolicy="true">
Lee O.
  • 3,212
  • 2
  • 26
  • 36
  • I'm getting the same error in my Unit Test project, and have added the above to my app.config. Yet I'm still getting the same error. (I'm trying to unit test the emailing of a PDF generated by a crystal report) – Shawn de Wet Apr 03 '13 at 05:09
  • When I add this section, another I get another error when I run the app CrystalDecisions.Shared.SharedUtils CrystalDecisions.ReportSource.ReportSourceFactory An unhandled exception of type 'System.TypeInitializationException' occurred in CrystalDecisions.Windows.Forms.dll – duardbr Mar 31 '16 at 13:45
7
 <startup useLegacyV2RuntimeActivationPolicy="true" >
    <supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0" />
 </startup>

Add this code in app.config.

Rajesh Abraham
  • 203
  • 1
  • 3
  • 10
0

You probably need to install the crystal reports runtime files. You should be able to do a google search to find them. The error message is pretty explicit in telling you the problem is a missing .dll. Read it ;)

edit: Try locating the crdb_adoplus.dll on your machine and copying it to the application directory.

Tom Studee
  • 10,316
  • 4
  • 38
  • 42
  • are you sure you installed the 64 bit version, and the correct 64 bit version? – Tom Studee Jun 07 '12 at 22:57
  • i am reinstalling the 64 bit version. – Rajesh Abraham Jun 07 '12 at 23:00
  • try what i suggested in my edit first. let me know if that works. – Tom Studee Jun 07 '12 at 23:01
  • whenever i change the target framework - '.NET Framework 3.5' it is working but '.NET Framework 4.0' its showing error .. why? have any idea?...please help.. – Rajesh Abraham Jun 07 '12 at 23:08
  • @RajeshAbraham Please, please stop saying "please help". And on that note. There is likely a different call in the 4.0 framework. If that file even exists in the 4.0 framework. – Drise Jun 07 '12 at 23:09
  • @RajeshAbraham I've had function calls change from framework to framework, once it was the difference from passing by val to by ref. If changing frameworks fixes it for you: 1) use the 3.5 framework or 2) find the updated call in the 4.0 framework. – Drise Jun 07 '12 at 23:21
  • @Drise thanks. I installed updated call in the 4.0 framework. but still showing same error. – Rajesh Abraham Jun 07 '12 at 23:32
  • ADD 'useLegacyV2RuntimeActivationPolicy="true" ' IN APP.CONFIG. – Rajesh Abraham Jun 08 '12 at 15:05