Skip to Content
Author's profile photo Ludek Uher

Creating Crystal reports User Function Libraries (UFL) with Visual Studio .NET

Introduction

A User Function Library (UFL) is a dynamic link library, created by an application developer. Crystal Reports is then able to use these UFLs to add customized functions to the formula language. In this way UFLs may remove the need to format data with complex formulas in order to get usable report output. UFLs essentially extend the Crystal Reports formula language and are used in the same way as any other predefined Crystal Reports functions. Additionally, complicated formulas, or a high number of formulas will result in report performance issues and UFLs may help to alleviate these issues as complex or difficult calculations are removed from Crystal Reports into an environment the developer has much more control over.

The ability of creating UFLs was added in version 6 of Crystal Reports and this ability persists through to version 12.x . These original UFLs had to be built in a COM compliant language (VB 6, C++, Delphi, etc.). With the release of Visual Studio .NET, Crystal Reports UFLs can now also be created using .NET.

Solution

A User Function Library (UFL) built in Visual Studio .NET is a .NET class library that has similar requirement to the original COM UFLs:
The project name must be prefixed with the string “CRUFL”.
Upon compilation, the assembly is registered for COM Interop so that it is viewed as a COM object.
The project consists of an interface and an implementation class.
Both the interface and the implementation class have COM and GUID attributes.
The User Function Library, is visible within the Crystal Reports Designer as a new function in the Formula Workshop under Additional Functions.

Additionally, the .NET assembly/COM (UFL) object must be added to the Global Assembly Cache so that it is available to all .NET applications on the machine.

Detailed documentation on creation, use and distribution of .NET UFLs can be found in the article, “Crystal Reports For Visual Studio 2005 Walkthroughs”, pages 390 to 399. Additional information can be found in the “Crystal Reports 2008 .NET SDK Developer Guide”, by searching the file for UFL.

 

Additional Resources

1603381 – How to create a C++ UFL using the new Unicode UFL interface in Crystal Reports 2008 & later

Migrating Applications from the RDC to the .NET assemblies

How to deploy Crystal Reports UFL created in Visual Studio .NET

UFL created in C#, Visual Studio .NET 2005 is not visible in the Crystal Reports Designer

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jorg Neeb
      Jorg Neeb

      Hi,

      is it possible to create two different ufls? I tried it but cr only recognizes the ufl which was build at last.

      regards

      joerg

      Author's profile photo Don Williams
      Don Williams

      Hi Jorg,

      Try searching first and Post to Forums - Yes you can create more than one, they just have to have different file names.

      See this KBA for examples:

      https://launchpad.support.sap.com/#/notes/1603381

      If the link does not work the search for 1603381

      Don