cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot load file or assembly

Former Member
0 Kudos

Ok so I just stumbled across something unusual. I am new to the vb.net with crystal reports so keep that in mind. I have two applications that I have built using Visual Studio Professional 2013 that are referencing the same crystal report. One of them will run my crystal report without issue, but the second one is throwing an error saying it cannot load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, version 13.0.2000.0 ......

It must be something in the configuration of the second vb app but darned if I can see the difference between the two projects. On my dev machine both apps work perfectly but on the enduser machines the same error is reported in the second application. It must be something in my project that is missing in the second program. Any help much appreciated.

Cheers

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Only reason it would try to log on is because you have one of the Verify Database options checked on.

To clarify, you are talking about when CR Designer logs the DB info, it will always try to log on without a password, it's always done that.

That error is always there, ignore it.

Odd Architect error, I don't recall ever seeing that one, sounds like a Windows message... whcih may suggest your MDAC drivers and ADO dependenciess may me "confused".

Don

Former Member
0 Kudos

Thanks to your help Don I am making progress. I noticed that even though I had marked my development package to be x86, it actually wasn't doing that. I had to go mark it in another spot of my project. I am getting some of my reports opening now without the logon dialog box. I suspect the other ones I have messed up by playing with the odbc dsn names.

0 Kudos

Cool... glad I could help....

Answers (2)

Answers (2)

Former Member
0 Kudos

So it appears that I have found part of the issue. There was a tickbox checked that says Prefer 32 bit under the compile options. When I turned that off and rebuilt the solution the program goes further but is now coughing on sending the database password. This one has me stumped because I know for a fact that the username and password that are being passed are indeed correct.

DellSC
Active Contributor
0 Kudos

Are you using ODBC connections?  Do both applications use the same ODBC connection or are they different?

What is the error that you're getting now?

-Dell

Former Member
0 Kudos

It is bringing up a database login screen. I notice that the database is not filled in. Since I posted my last response I noticed something else. The report that appeared to be working was in face using saved data so it was not querying the database. When I changed that, it too is prompting for logon information now in the app that I thought was working. So I have a consistent problem now.

DellSC
Active Contributor
0 Kudos

How are you setting the logons for your reports?  You need to explicitly do that in code and how you do it depends on which object model you're using - CrystalReportViewer, ReportDocument, or ReportClientDocument.

-Dell

0 Kudos

Hi Scott,

First what SP are you using? 13.0.2000.0 is the assembly version, it never changes.

Look in Programs and feature or the Assembly folder for the file version.

If you are not up to SP 17 then do that first.

Second what is the PLATFORM you want to use, 32 or 64 bit? Doesn't matter if it sort of works.

If 32 bit then set your project properties to x86, build it and deploy your app to the users PC.

Uninstall what you had if it's not SP 17 and then install the SP 17 on the other PC.

Setup the DSN located in the \syswow64\odbcadm32.exe

If 64 bit then change your project to x64 and create the DSN in \system32\odbcadm32.exe

The reason the Server and DB are blank or grayed out is because CR can't find the DSN or client.

Don

Former Member
0 Kudos

I'm using 17 as 32 bit. The odbc works fine as I have connected to it using another much older reporting tool. I tried setting to x86 as suggested but I still get the dialog box for the login information.

To answer Dells question I am using crystalreportviewer with reportdocument. I have tried setting the login information with setdatabaselogon and that part succeeds. It is when I assign the reportdocument object to the reportviewer reportsource that it seems to blow up. I also tried some example code that sets a connection and passes the login information for each table of the report. The code seems to execute all of that without issues. It when the reportviewer get the reportdocument object that it blows apart.

DellSC
Active Contributor
0 Kudos

If you are using ReportDocument, you need to set the table logons after you load the report and before you use it to set the ReportSource of the viewer.

Here is sample code from one of the links at the top of this space:

Step 1:  Set the logons in the Report Document and put it in a session

    protected void btnSubmit_Click(object sender, EventArgs e)

    {

        // Load the Report

        ReportDocument boReportDocument = new ReportDocument();

        boReportDocument.Load(Server.MapPath("Northwind SQL.rpt"));

        // Create a ConnectionInfo

        ConnectionInfo boConnectionInfo = new ConnectionInfo();

        boConnectionInfo.ServerName = txtServer.Text;

        boConnectionInfo.DatabaseName = txtDatabase.Text;

        boConnectionInfo.UserID = txtUserID.Text;

        boConnectionInfo.Password = txtPassword.Text;

        // Modify the ConnectionInfo for all tables in the main report       

        ModifyConnectionInfo(boReportDocument.Database, boConnectionInfo);      

        // Modify the ConnectionInfo for all tables in all subreports

        foreach (ReportDocument boSubreport in boReportDocument.Subreports)

        {

            ModifyConnectionInfo(boSubreport.Database, boConnectionInfo);

        }

        // Store the ReportDocument in HttpSession for use on the next page.

        // Remember to Close() Dispose this later when not needed.

        Session.Add("Report", boReportDocument);

        Response.Redirect("viewreport.aspx");

    }

    private void ModifyConnectionInfo(CrystalDecisions.CrystalReports.Engine.Database boDatabase, ConnectionInfo boConnectionInfo)

    {

        // Loop through each Table in the Database and apply the changes

        foreach (CrystalDecisions.CrystalReports.Engine.Table boTable in boDatabase.Tables)

        {

            TableLogOnInfo boTableLogOnInfo = (TableLogOnInfo)boTable.LogOnInfo.Clone();

            boTableLogOnInfo.ConnectionInfo = boConnectionInfo;

          

            boTable.ApplyLogOnInfo(boTableLogOnInfo);

            // The location may need to be updated if the fully qualified name changes.

            //boTable.Location = "";  

        }      

    }

Step 2:  Assign the ReportDocument to the viewer

public partial class viewreport : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        // Make sure there is a report in session

        if (Session["Report"] == null)

            Response.Redirect("default.aspx");

        // Set the ReportSource of the viewer to the ReportDocument stored in session

        CrystalReportViewer1.ReportSource = Session["Report"];

    }

    protected void btnClose_Click(object sender, EventArgs e)

    {

        // Clean-up code for Crystal Reports - Don't forget to do this when you're done with the report...

        CrystalDecisions.CrystalReports.Engine.ReportDocument boReportDocument = (CrystalDecisions.CrystalReports.Engine.ReportDocument)Session["Report"];

        boReportDocument.Close();

        boReportDocument.Dispose();

        Response.Redirect("default.aspx");

    }

}

-Dell

Former Member
0 Kudos

I tried something very similar and I watched it run through the code setting the connection info for the database table. It is the point where I assign reportsource that it blows apart.

And now that I have set it to be x86 it is back to the cannot load file or assembly thing.

0 Kudos

You said you were using a much older piece of software and it connects. Is the old connection using ODBC 2?

Open the report in CR Designer and export to RPT format, this saves data with the report. Or refresh the report and save data with it.

Now in a simple WEB app using the code below load the report and preview it.

Now hit the Viewers Refresh button, this should prompt you for DB connection info according to the database connection info saved in the Report. If the Server or DB name is grayed out it means the application CAN NOT find the DB client, it's as simple as that.

Make sure IIS is running under an system account and that system account has access to the DB client.

Enable CRLogger, search for how to, run that on the app server when CR runtime is installed and see what it shows for the report with saved data and your app.

Keeping the report in Session and Postback is a must:

public partial class _Default : System.Web.UI.Page

{

        CrystalDecisions.CrystalReports.Engine.ReportDocument rd;

        CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

    protected void Page_Init(object sender, EventArgs e)

    {

        rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        CrystalDecisions.CrystalReports.Engine.Database crDatabase;

        CrystalDecisions.CrystalReports.Engine.Tables crTables;

        CrystalDecisions.Shared.TableLogOnInfo tblogoninfo;

        CrystalDecisions.Shared.ConnectionInfo cninfo;

        string url = @"D:/Atest/MyReport.rpt";

        rd.FileName = url;

        #region Session

        if (Session["rd"] == null)

        {

            try

            {

                rd.Load(url, OpenReportMethod.OpenReportByTempCopy);

                rptClientDoc = (CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper)rd.ReportClientDocument;

                // not using RAS then use

                // Session.Add("rd", rd);

                Session.Add("rd", rptClientDoc.ReportSource);

            }

            finally

            {

                // open the database connection

                //myConnection.Close();

                //rptClientDoc = rd.ReportClientDocument;

            }

        }

        #endregion Session

        CrystalReportViewer1.Height = 300;

        CrystalReportViewer1.Width = 300;

        CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;

        // set up the format export types:

        int myFOpts = (int)(

            CrystalDecisions.Shared.ViewerExportFormats.RptFormat |

            CrystalDecisions.Shared.ViewerExportFormats.PdfFormat |

            CrystalDecisions.Shared.ViewerExportFormats.RptrFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.XLSXFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.CsvFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.EditableRtfFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.ExcelRecordFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.RtfFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.WordFormat |

            CrystalDecisions.Shared.ViewerExportFormats.XmlFormat |

            CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat |

            //CrystalDecisions.Shared.ViewerExportFormats.AllFormats |

            CrystalDecisions.Shared.ViewerExportFormats.ExcelRecordFormat);

        //CrystalDecisions.Shared.ViewerExportFormats.NoFormat); // no exports allowed

        //int myFOpts = (int)(CrystalDecisions.Shared.ViewerExportFormats.AllFormats);

        CrystalReportViewer1.AllowedExportFormats = myFOpts;

        CrystalReportViewer1.ID = "ReportUsageDetailByArea";

   

    // this sets the report to the session

        CrystalReportViewer1.ReportSource = Session["rd"];

        CrystalReportViewer1.EnableParameterPrompt = true;

        CrystalReportViewer1.HasToggleParameterPanelButton = true;

    }   

        rd.Close();

        rd.Dispose();

}

If all of that does  not work try repairing VS and CR for VS, make sure you are a local PC admin and your AV software is not blocking access to anything CR runtime.

Try searching for what ever error you are getting also, with the missing assembly.

Don

Former Member
0 Kudos

Ok, so I stepped away from this for a couple of weeks just to get some other work completed and give it a break. As a test, I created a new ODBC connection which uses Driver 11 for SQL Server. I created a brand new report that accesses two tables. I then recreated the ODBC connection on a client computer. I have since loaded a demo of cyrstal reports on the client machine so that I could open the report in cr and it runs fine on that computer under crystal reports. When I call this report in the crystal viewer however it brings up the logon screen and tells me that it failed the logon. The server name, database name, login id are all correct on this screen and I know I am giving it the correct password. Why will it run perfectly in crystal reports but not when being called from visual studio using crystal reports viewer??? The exact same activity happens on the client pc and my development pc.

former_member207665
Active Participant
0 Kudos

Hi Scott,

What happens when you open the Crystal Report in the Visual Studio Embedded Crystal Reports Designer 13 version?

Regards,

Vinit

Former Member
0 Kudos

When in visual studio, when I add it to the project and open it, I can preview it at which point it prompts for the password like when I am calling it from the report viewer but it accepts the password and generates the report.

0 Kudos

OK then check your code again.

Try downloading my Parameter test app, Doc-70646, it has the ability to set log on info also.

Fill in the values in the UI and see if that works.

Don

former_member207665
Active Participant
0 Kudos

Can you check the event viewer for the exact error message? Would request you to share it.

Former Member
0 Kudos

I don't see anything in the event viewer that seems to be relevant. Mind you I am not fluent with this tool. Where exactly should I be looking in this tool for more information?

Former Member
0 Kudos

This is the code I have on my end.

former_member207665
Active Participant
0 Kudos

Hi Scott,

Try removing the line cr.SetdatabaseLogon() from your code.

Regards,

Vinit

0 Kudos

And remove the .Refresh(), that can over write what you just set.

Try adding CRTable.TestConnectivity() and see if it returns true.

Don

Former Member
0 Kudos

Interesting, the testconnectivity method fails on each table.

Former Member
0 Kudos

Still get the login screen, but after putting in Don Williams suggestion I see if it failing on each table with the connection for some reason.

former_member207665
Active Participant
0 Kudos

Hi Scott,

I have attached a sample code for setting the DB logon. It will only set the DB logon, if it is successful it will ask you for parameters. Let it do that pass them manually and then we can pass the parameters from code as next step. For now lets just troubleshoot the DB logon.

I did not get your previous update. Can you be more specific when is the test connectivity failing.

Regards,

Vinit

Former Member
0 Kudos

I was checking the connectivity after each table has the security applied. I ran your code that you attached but supplied my report and logon information. It is still telling me there is a failed login. Everything looks correct, I even tried giving a bogus server name and failed right away with a different message so I know part of it is working correctly.

Former Member
0 Kudos

Just for the fun of it. I added a new form and dropped on the crystal report viewer. I used the drop down menu of that object to create a brand new report from scratch that uses one table with only a handful of rows in it. No prompts or anything, simply a list view. I can preview the data just fine while in Visual studio in design mode of the report. However, when I go to run the application in debug mode, it stops me asking for login information when I open this form.

0 Kudos

Curious, in your code are you specifying the DSN name or the actual Server name? If using ODBC it must be the DSN name.

Did you use the 32 bit ODBC Admin or 64 bit? Shoudl be in the \syswow64 folder to create the 32 bit DSN.

Don

Former Member
0 Kudos

Everything looks correct to me. Here is a screen shot of the table logon properties when it fails on the testconnectivity.

0 Kudos

OK,

SQLtest is your DSN name correct?

Enable CRLogger and see what it reports:

Add these to your System Environment variables:

LOGGING_DIR = c:\logging

LOGGING_ENABLED_ASSERT = 1

LOGGING_ENABLED_RUNTIME = 30

It will affect performance so set ASSERT = 0 to turn it off or remove them.

Don

Former Member
0 Kudos

You will have to forgive my ignorance here Don. I am taking it that there is an ini or more likely xml file that I need to add these options in order to enable the logging tools. Can you direct me as to what folder this would be in. There is like a gazillion subfolders in my \program files(x86)\sap business objects.

0 Kudos

Nope, from the Start menu in Windows Search type in System Environment, it's not a CR part, and it will allow you to edit them.

Create a folder on your C drive and label it "logging"

Add the 3 variables and restart your app and/or CR Designer and it will start generating the database log with our API's used.

The file used is crlogger.dll, it comes with CR Designer and SDK's.

Don

0 Kudos

Here's some screen shots if you still don't know what Environment Variables are:

Windows 7 may need to be re-booted to take affect.

Don

Former Member
0 Kudos

Ah ok, now I got you. I will reboot to be on the safe side. This machine is Windows 8.1. I'll let you know what I find out.

Former Member
0 Kudos

Ok I am making head way now Don. The logs are telling me that there is a architecture mismatch between the driver and the application. This is quite curious because as a test I created a new odbc connection called SQLTest to create a new report from so that there would be no doubt which odbc was being used.

Former Member
0 Kudos

Just for the fun of it, I opened crystal reports up and loaded up the report. It also reports an instance of logon failure to this datasource but then there is a second successful login after that recording. I am assuming that it tries to connect to the database when you open a report but it doesn't have the password and thus fails? Also, right at the top of the log file for crystal reports there is an error reported as follows:

..\cserrif.cpp 523 Error 14722 (..\csdll.cpp, 117): : c:\Program Files (X86) SAP Business Objects\SAP BusinessObjects Enterprise XI 4.0\win32_86\crw32_res_xx.dll

DellSC
Active Contributor
0 Kudos

Have both applications been installed an the same machines?  If not, are you installing the Crystal for VS runtime on all of the machines?  Does the application you're having issues with work when it's installed on the same machine where the other appliction does work?

Note that the "bit-ness" of the runtime MUST match the bit-ness of the application, which may not be the same as the bit-ness of the computer.  So, if you're compiling the application as 32-bit, you must install the 32-bit runtime, regardless of whether the machine is 32-bit or 64-bit.

-Dell

Former Member
0 Kudos

A have two machine on the network that are running both of these applications. One application will display the crystal report on both computers. The second application fails on both computers which tells me that the runtime environment is configured correctly, but that I have missed something on the second application in the project. I have the added references to the crystal decisions dll files in both applications. I know it is some simple little thing.