Search code examples
c#asp.netcrystal-reports

.NET Crystal Report Error : The type or namespace name 'ReportDocument' could not be found (are you missing a using directive or an assembly ref...?)


I have a project that I am porting from Visual Studio 2012 in Windows 7 to Visual Studio 2017 in Windows 10. The project builds and ran fine on the older machine. The project uses Crystal Report.

There were multiple errors while I try to publish the project using the new machine with VS 2017. The 1st error complained: CS0246 The type or namespace name 'ReportDocument' could not be found (are you missing a using directive or an assembly reference?) Navi C:\VS\Navi\Picking.aspx.cs 89 Active

The line 89 of the file says:

public ReportDocument rpt
    {
        get
        {
            return (ReportDocument)Session["PickHeaderrpt"];
        }
        set
        {
            Session["PickHeaderrpt"] = value;
        }
    }

I have 3 using that are greyed out (not used??):

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Configuration;

I have installed Crystal Report for Visual Studio, version 13_0_22 from my downloaded file. It seems like it is missing some references, but I am still confused about what the problem is?


Solution

  • The problem here is that the project was missing some dlls. While I ported the code from Windows 7 and VS 2012 to Windows 10 and VS 2017, the original Crystal Report installed libraries/dll was missing in the new laptop. Installing the newest Crystal Report for VS 2017 (ver 13_0_22) does not solve the misssing dlls issue, due to differences in the structure in the newest Crystal Report.

    I solved this by reinstalling VS 2012 and Crytal Report for VS 2008/2012 (ver 13_0_7). I luckily found this on my old HDD. Doing this/reinstalling the old version of Crystal Report on the new Windows 10 laptop cleared me of all the errors associated with missing Crystal Report dlls problems. It even allowed me to run the project on the VS 2017.