Symptom
- This sample allows the report designer to set localized string values
- Attached zip file contains sample C# .NET User Function Library source code as well as a sample report
Environment
Visual Studio .NET
Resolution
- To use this UFL you need to register it with VS .NET
- Use the regasm command line tool (C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe)
- This UFL only works with Crystal Reports 2008 Service Pack 1 and higher
- For more details see the readme.txt file included in the attached zip file
Also Note:
To change the Class Name so the function name (DotNetSampleClass) is not listed in Crystal Report Designer do the following:
- Click on the View menu in .NET IDE and select Show Class View.
- Then right click on the class and select Rename.
- The delete all but "CRUFL"
- Click the OK button and yes to the next prompt to confirm the name change.
- Do the same for the "Class Test" and change it to something like "Fnt".
Now you will see the function named: Fnt StringLength.
To be able to use the UFL in CR Designer you need to tell the Designer to use the same framework by doing the folowing:
To see this new UFL in Crystal report Designer do the following:
-
Crystal Report Designer 2011/2013 is a 32 bit app so the UFL MUST be compiled in x86 mode. If you plan to use the UFL in a 64 bit application then you need a separate 64 bit version:
-
Copy the file and for CR 2008 place it in this folder:
-
C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86
-
For CR 2011/2013 in this folder:
-
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86
-
CR for VS is the only 64 bit runtime we have except for BI 4.x also may require it. Depending on the CR Processing Server it may need the 64 bit UFL and 32 bit UFL.
For 32 bit App:
-
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86
-
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86
64 bit App:
-
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64
-
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x64
To be able to set Crystal Report Designer to use the same Framework you created the UFL in you must tell CR Designer whcih one to use by doing the following:
Create a file called:
crw32.exe.config
And paste this into it:
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true" >
<supportedRuntime version="v4.0" />
</startup>
</configuration>
Change the "supportedRuntime version" to what ever framework you are compiling your UFL in.
Save this file into the same location as crw32.exe:
For CR 2011/2013:
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86
And for CR 2008:
C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86
Now you should see your functions in the list in CR Designer.
For CR 2020 you need a 64 bit version of the UFL:
Create a file called:
crw64.exe.config
And paste this into it:
<?xml version ="1.0"?>
<configuration>
<supportedRuntime version="v4.0" />
</startup>
</configuration>
Change the "supportedRuntime version" to what ever framework you are compiling your UFL in.
Save this file into the same location as crw64.exe:
For CR 2020:
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win64_x64
See Also
- Blog; Creating Crystal reports User Function Libraries (UFL) with Visual Studio .NET
- For information on creating a C++ UFL see KBA 1603381 - How to create a C++ UFL using the new Unicode UFL interface in Crystal Reports 2008 & later
Keywords
.NET UFL UNICODE String UFL user function library visual studio VS , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To
Product
Attachments
CRUFLDotNetSample.zip |