Sunday, March 18, 2012

Using Crystal Reports for Visual Studio 2010 Merge Modules (MSM) to create a Setup project

Purpose

This wiki details the steps necessary to ensure successful deployment of Crystal Reports for Visual Studio 2010 runtime. The wiki is strictly limited to deployment of CRVS2010 runtime only and does not describe any additional intricacies of setup projects as these are beyond the scope of Crystal Reports. For detail beyond the scope of this wiki, see Microsoft documentation.

Overview

Using the Crystal Reports for Visual Studio 2010 merge modules (MSM files) requires additional dependencies. These must be added and installed on a client computer before the Crystal Reports runtime. An additional merge modules is required if the reports take advantage of the Crystal Reports mapping feature (MapInfo MapX). If the project requires localized reporting, localization mege modules must also be added to the deployment project.

Building the project

Open Visual Studio 2010 and select New Project. From the Templates pane select “Other Project Types” then “Visual Studio Installer” and finally “Setup Project”. Fill out the name of the setup project and select the location where you want the project to be saved to. 
In the “Solution Explorer”, right click on your project name. In the popup menu, hover over “Add” and select Merge Module... 
Do not select File. This will not add the msm file as a merge module, thus leading to errors when a report is attempted to be loaded by the deployed application. The following is an example of an expected error:
An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'CrystalDecisions.Windows.Forms, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.

Select CRRuntime_13_x.msm. The x in the msm name denotes the Service Pack of the merge module. If your application is to be localized, add the required localization merge module.
 The CRRuntime_13_x.msm is a configurable merge module. The configuration allows the developer to remove unwanted database driver dlls. To see dlls that can be removed from the merge module, click on the msm file name in the Solution Explorer. In the Properties, expand the "ModuleProperties" node. Any and all of the listed dlls can be removed by simply setting their property to 0 (zero). Ensure that database driver dll or dlls required by the report are not excluded(!).
The next step is to ensure that the Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update  is included in the deployment project. This is a Crystal Reports for Visual Studio 2010 dependency. The actual Microsoft Visual C++ 2005 merge modules are; Microsoft_VC80_CRT_x86.msm, Microsoft_VC80_MFC_x86.msm, Microsoft_VC80_ATL_x86.msm and Microsoft_VC80_OpenMP_x86.msm
It is up to the developer of the application to ensure that this dependency is either included in the setup project and installed before the Crystal Reports runtime. Or, that the client computer has been updated with the dependency before running the setup project. Missing dependencies will cause errors regarding faillure to register a number of files on install of the setup project. The following is a typical error produced if the C++ dependencies are missing:
Module C:\Program Files\SAP Business Objects\Crystal Reports for .NET Framework 
4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\crtslv.dll failed to 
register. HRESULT -214010895. Contact your support personnel.

The final step is compiling the application. The setup executable will be in the Release folder. 

Localization Merge Modules

Note that the English runtime msm is called CRRuntime_13_x.msm. However, along with this msm, you will find a number of language msm files. For example CRRuntime_13_x_de.msm. This is a localization support msm file - German in this case. Languages supported include Spanish, Japanese, Korean and more. For more information regarding localization of Crystal Reports see the SAP Crystal Reports .Net SDK Developer Guide, where topics discussed include the following:
  • Setting up the custom resources file directory
  • Configuring multilingual client support for Windows application
  • To configure browser-based localization
  • Language Resource Files
  • Compiling the resource files
  • To configure Page-Based localization for a web page
  • To configure environment-based localization for a website

MapInfo MapX Merge Modules

One additional MSM file to be aware of is CRRuntime_13_x_maps.msm. This MSM is required if your reports use the Crystal Reports mapping feature. For more information see the KBase 1529045 - CRVS2010 - How to create and distribute runtime for reports using MapInfo MapX?.

 32 Bit vs. 64 bit Applicaton Deployment

It is important to understand that the VS2010 IDE is 32 bit and thus any project running within the VS2010 IDE is 32 bit. When a project is compiled in a 64 bit mode, it can not be tested in the VS2010 IDE. As there are no 64 bit merge modules for CRVS2010, deployment of 64 bit applications will have to be done via the use of the 64 bit MSI file. For more details and considerations regarding 32 bit and 64 bit deployments, see the article Crystal Reports support of 64 bit Operating Systems.

Deploying Custom User Function Libraries

 User Function Library (UFL) is dynamic link library (DLL), created by an application developer. As this is essentially "3rd party" DLL, it is not included in any merge module and thus it is up to the application developer to ensure that this custom dll is deployed and configured correctly on any client computer. Note that there are three types of UFLs, each with it's own set of deployment and configuration requirements. The types of UFLs are C+, COM and .NET. C+ UFLs simply need to be installed into a directory where the application will be able to find it. The CRVS2010 bin directory is suggested (C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86). COM UFLs can be deployed to any directory, but must be registered using regsvr32.exe. VS .NET UFLs  must be added to the Global Assembly Cache. For more information on VS .NET UFLs, see the blog Creating Crystal reports User Function Libraries (UFL) with Visual Studio .NET

 Deploying XML Based Reports Using CRDB_XML.DLL Database Driver

The databse driver CRDB_XML.DLL is not included with any version of Crystal Reports that bundles with VS .NET. This includes CR 9.1 (VS 2003), CR 10.2 (VS 2005) and CR 10.5 (VS 2008).  CVS2010 also does not include the CRDB_XML.DLL.  All stand-alone versions of Crystal Reports include the CRDB_XML.DLL driver. However, the driver requires the installation of the Java framework. No Crystal Reports MSM or MSI file installs or configures the Java framework. For details see KBase 1594651 - CRVS2010 - Error: 'Failed To Load Database Information' when using XML file as datasource on how to obtain the DLL for CRVS2010. See KBase 1394940 - How to deploy Crystal Reports 2008 runtime for .NET when the report is connecting to XML files? on how to deploy the CRDB_XML.DLL.

Last Word

Ensure the the report files is added to the deployment project
Reports added to the application as a strongly-typed object do not need to be added to the setup project
Ensure the runtime is supported on the Operating System. For more information see the wiki Crystal Reports for Visual Studio .NET Runtime Distribution - Versions 9.1 to 12.0
Fix Packs, Service Packs or any other updates for CRVS2010 cannot be applied directly to a deployed computer

No comments:

Post a Comment