Tuesday, September 19, 2006

Could not load file or assembly 'CrystalDecisions.CrystalReports'

I managed to get hold of Visual Studio 2005, and like any new programmers, I was rubbing my hands in glee at getting the latest toolkit for development.

When I tried to open an existing file in Visual Studio 2005, it prompted me to upgrade to the .NET framework and create a new webconfig file. Then my nightmare with debugging begins, especially with Crystal Reports. In particular, this error got me stumped

Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine visual studio 2005 .

The error occurs in the web.config file.

add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3000.0, Culture=neutral, PublicKeyToken="

I tried everything I knew, googling it, getting deployment packages from BusinessObjects etc. But none of them work as all I want is to compile my code without the darn error and make sure the migration to .NET 2.0 is successful.

So after sitting in the dark without a clue to what the error may be for an hour and fed up with reading tons of articles that don't work, I decided I have enough of googling and time to do something. As a first step, I open the bin folder, and check the Crystall report dll. Oops! There is the darn error! The version number for the old dll is 9.1.9800.9 and the assembly version is 10.2.3000.0! So I delete all the dll, and add the new CrystalReport dll.

To my surprise, Visual Studio version number is higher than what the assembly version is 10.2.5150.0. Thinking myself smart, I did what I think is right and changed the assembly in the web.config file to

add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.5150.0, Culture=neutral, PublicKeyToken="

Then I found out that there is no such assembly in the .NET 2.0. Only the Version 10.2.3000.0 is there in the assembly. All attempts to add the new version into the assembly failed. Since I cannot edit the assembly, I tried changing it back the original version:

add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3000.0, Culture=neutral, PublicKeyToken="

And hey pesto, everything suddenly can compile!

Morale of story: Make sure your dlls in the bin directory in your new .NET 2.0 application is updated to the latest version and leave the assembly code in the web.config file alone. It saves you a lot of pain in migrating to .NET 2.0.

4 comments:

  1. Hi Eugene,

    That's a great article thanks. I have the same problem. I am trying to compile a webpage and I get the same error. So, I followed your steps and open BIN. But there is no CrystalReports dll there?? So, how can I put it? Where can I put it from?

    I hope you have time to answer me.

    Best Regards,
    Vural ASLAN
    E-mail: gercekaslan@yahoo.com

    PS: I used to live in Singapore. It is a wonderful place, but now I am in USA. I really miss Singapore sometimes.

    ReplyDelete
  2. For 32-bit Windows applications/Web Sites use CrystalReportsRedist2005_X86.msm
    For x64 (AMD64) Windows applications/Web Sites use CrystalReportsRedist2005_X64.msm
    For IA64 (Itanium) Windows applications/Web Sites use CrystalReportsRedist2005_IA64.msm

    The 32-bit merge module is here:
    http://support.businessobjects.com/communityCS/FilesAndUpdates/cr_net_2005_mergemodules_mlb_x86.zip.asp

    ReplyDelete
  3. I did it before,it's difficult to me,but not to you
    document finder

    ReplyDelete