5

I'm a novice in the windows form application. It's my first application at the office. My office management gives me the source code. But they don't know anything about it.

I run those codes on visual studio 12 (64 bit). Everything is running, but the crystal report is not working. Throws error.

error is:

Unable to cast COM object of type 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' to interface type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

here is the screenshot:

enter image description here

here is the code:

ReportDAL rDal = new ReportDAL();
            receipt r = new receipt();


            DataTable dt = rDal.GetInvoiceHeader(vId);

            //string ww = GetInvoiceHeader(vId);
            r.Database.Tables["ReceiptDetails"].SetDataSource(rDal.GetInvoiceDetails(vId));
            r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId));
            r.SetParameterValue("pReportDeliveryTime", GlobalData.reportDeliveryTime);
            crystalReportViewer1.ReportSource = r;

Can anyone give me a solution elaborately?

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
  • did you install crystal reports? – Allanckw Oct 04 '17 at 03:18
  • 1
    Which VS & CR version(s) used? Check your project references list, try remove & re-adding required references depending on installed CR version. – Tetsuya Yamamoto Oct 04 '17 at 03:19
  • I'm using visual studio 2012 and crystal report CRforVS_13_0_21 both are 64 bit. But I believe this source code was written in visual studio 10 / 08 . So What can I do now ? –  Oct 04 '17 at 03:26
  • Try registering CR DLL files in GAC by using `gacutil`, e.g. `gacutil /i [DLL_path]` (all DLL files begin with `CrystalDecisions`). Also make sure that `CrystalDecisions.ReportAppServer.Controllers` exist in `%windir%\assembly` folder. – Tetsuya Yamamoto Oct 04 '17 at 03:34
  • This fixed it for me: https://stackoverflow.com/questions/49123366/unable-to-cast-com-object-of-type-crystaldecisions-reportappserver-controllers – Steve Greene Jan 31 '19 at 21:52

2 Answers2

9

The same problem occured with me too, right now.

When I installed CR 13 Update 21, my project gave the same exception during runtime.

I just removed all of the references of CrystalDecision from Solution Explorer (which actually belonged to a previous version of CR i.e. CR 13 Update 20).

Then I added fresh references from Solution Explorer => References => Add Reference menu. I selected the required CrystalDecision packages from the window. Rebuilt, and the problem is gone now. enter image description here

Hainan Zhao
  • 1,962
  • 19
  • 19
shahsani
  • 687
  • 7
  • 16
2

Please install the lower runtime version of Crystal report in client Computer. Then it will be working fine. Like currently you are using vs2012 cr runtime then use runtime of 2008 it will be working fine.

I have the same issue but now I changed to lower version then it works fine for me.

parth
  • 91
  • 1
  • 10
  • 1
    Thanks @parth. In case someone wants to change the version https://www.tektutorialshub.com/download-crystal-reports-for-visual-studio/ – Baqer Naqvi Feb 24 '18 at 22:07