SAP Knowledge Base Article - Public

1548993 - Server Error in '/' Application when running .NET Web Application using Crystal Reports for Visual Studio 2010

Symptom

  • Running a .NET Web Application in Visual Studio that uses the Crystal Reports for Visual Studio 2010 SDK.
  • Using the Cassini, WebDev.WebServer40.exe, file system web server.
  • Error is thrown when attempting to run/test the web application.
    • Could not load file or assembly 'Crystal2010_WebApplication_x86' or one of its dependencies. An attempt was made to load a program with an incorrect format.
    • , or Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Error

Server Error in '/' Application.

 

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Crystal2010_WebApplication_x86' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Assembly Load Trace: The following information can be helpful to determine why the assembly 'Crystal2010_WebApplication_x86' could not be loaded.

=== Pre-bind state information ===
LOG: User = CONFIG17958VM0\UseIfAdminDisabled
LOG: DisplayName = Crystal2010_WebApplication_x86
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Crystal2010_WebApplication_x86 | Domain ID: 5
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/users/admin/documents/visual studio 2010/Projects/Crystal2010_WebApplication_x86/Crystal2010_WebApplication_x86/
LOG: Initial PrivatePath = c:\users\admin\documents\visual studio 2010\Projects\Crystal2010_WebApplication_x86\Crystal2010_WebApplication_x86\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\users\admin\documents\visual studio 2010\Projects\Crystal2010_WebApplication_x86\Crystal2010_WebApplication_x86\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7558ea1/5afae536/Crystal2010_WebApplication_x86.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c7558ea1/5afae536/Crystal2010_WebApplication_x86/Crystal2010_WebApplication_x86.DLL.
LOG: Attempting download of new URL file:///c:/users/admin/documents/visual studio 2010/Projects/Crystal2010_WebApplication_x86/Crystal2010_WebApplication_x86/bin/Crystal2010_WebApplication_x86.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.


Stack Trace:

[BadImageFormatException: Could not load file or assembly 'Crystal2010_WebApplication_x86' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'Crystal2010_WebApplication_x86' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591

[HttpException (0x80004005): Could not load file or assembly 'Crystal2010_WebApplication_x86' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Environment

  • Windows Vista x64, or Windows 7 x64
  • Visual Studio 2010
  • Crystal Reports for Visual Studio 2010, RTM (13.0.0.99)
  • .NET Web Application Project

Reproducing the Issue

  1. Create a new Web Application Project in Visual Studio 2010.
  2. Make sure it is a File System web site, not running on IIS.
  3. Add a CrystalReportViewer control, or Crystal Report to the project.
  4. Attempt to preview the web site.

Cause

  • Errors like this are caused because the Web Application is built to target x64 or Any CPU.
  • The built in web server used for File System web applications, called Cassini (WebDev.WebServer40.exe), is a 32 bit application.
  • When x64 or Any CPU are selected as the platform target the 32 bit WebDev.WebServer40.exe attempts to load 64 bit assemblies and other images into a 32 bit memory space and errors occur.

Resolution

  • The File System web applications can't be used in x64 or Any CPU mode on a 64 bit operating system.
  • Ensure your Platform target is set to x86 on your development server if you are going to use File System web sites.
  • To change your Platform target:
    1. Open the Solution Explorer in Visual Studio.
    2. Right click your Project and select Properties.
    3. Click the Build tab.
    4. Set the Platform target to x86.

web application platform target properties.png

Keywords

KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio