SAP Knowledge Base Article - Public

2525898 - Could not load file or assembly 'BusinessObjects.Enterprise.Sdk' or one of its dependencies

Symptom

We recently finished migrating our CR from an old version to the new Crystal Report Server 2016 SP04.

We are in the process of migrating our applications and web services to use the newer DLL versions of this new platform. One of the most important of the applications that need to be converted is the one that open one or more Crystal Reports (CR), pass parameter values and then save the report as pdf. This application worked perfectly under the older version of Crystal Enterprise server but on the CRS 2016 installation is giving us headaches. After much reading on the SAP portal documentation and elsewhere on the web we were able to make it run successfully on the development tool (Visual Studio 2016).

Here is the actual code that do the work:

ReportDocument cryRpt = new ReportDocument();

cryRpt.Load(reportName);               // pass the logon credentials

ConnectionInfo crConnectionInfo = new ConnectionInfo

{

ServerName = GetConfigKeyValue("DBServer"),

DatabaseName = GetConfigKeyValue("DBName"),

UserID = GetConfigKeyValue("DBUser"),

Password = GetConfigKeyValue("DBPwd")

};

var crTables = cryRpt.Database.Tables;

foreach (Table crTable in crTables)

{

var crtableLogoninfo = crTable.LogOnInfo;

crtableLogoninfo.ConnectionInfo = crConnectionInfo;

crTable.ApplyLogOnInfo(crtableLogoninfo);

}

int y = 0;

foreach (string parameterName in cmcParameterCollection)

{

if (queryParamList != null) cryRpt.SetParameterValue(parameterName, queryParamList[y]);

y++;

}

cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fullPathTempPdfFile);

cryRpt.Close();

cryRpt.Dispose();

The problem comes when we try to migrate the application to the production web server. The application complies without problems but when we try to publish it on our production server it errors out with the following:

Could not load file or assembly 'BusinessObjects.Enterprise.Sdk' or one of its dependencies. An attempt was made to load a program with an incorrect format.

No matter what we do (re-reference the DLLs, create a new application from scratch, move the publishing to a different server) we get the same error. We even tried to add as many Crystal and Business Object dlls as possible in the references but still the error persists. We installed the latest BO .NET SDK (both 32 and 64 bit) and even the CR for Visual Studio Runtimes (again, both 32 and 64 bit) but no success.

We even installed Visual Studio in the actual production server where the CRS 2016 is installed (a big security risk but our desperation forced us to take desperate measures) and created the deployment package there but the final outcome is the same: the 'BusinessObjects.Enterprise.Sdk' assembly still has problems.

 

Environment

Crystal reports for Visual Studio

Resolution

I noticed in Visual Studio that , when I compiled the project in debug mode ,it did not show the same messages that where generated when I compiled in Release mode. Further investigation on the messages make me realize that when I compiled in RELEASE mode the compiler, for some reason, changed the platform target from x86 to AnyCPU. Since I was compiling for an x86 target, I just changed the Platform target manually to x86, and recompiled again. And, a compilation error appeared stating that the Code Analysis on Build feature on Visual Studio was finding a mismatch in the BusinessObjects.Enterprise.Sdk dll, the same error that started this case. I then suppressed the Code Analysis feature on VS and recompiled, making sure that I selected x86 as target platform and the project compile in RELEASE mode successfully. Then I published and browsed and, finally, I was greeted with a correct asp.net page! So far I have made more than 20 tests and the web service is successfully reading and converting all our Crystal Reports to pdf without any problem whatsoever.

So, then two things I think corrected the problem: Make sure that the x86 target platform is selected when compiling in Release mode and not using The Code Analysis on Build feature when compiling in Visual Studio. And since the error as happening in compiling time, that is why you never saw the web service bring up any Crystal dll to memory.

Keywords

Could not load file or assembly 'BusinessObjects.Enterprise.Sdk' or one of its dependencies , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Server 2016