on 05-12-2016 4:53 PM
We are working on creating a UFL to access a custom method in Additional Functions in CR2013 Designer. We followed the article “Creating Crystal reports User Function Libraries (UFL) with Visual Studio .NET” by Ludek Uher in SCN and deployed the DLL in GAC and registered with RegAsm as well. But we are unable to see the methods in Additional Functions. We do not see any folder for u212com.dll.
Here's what we have done in detail:
We created a .NET class library with the project name CRUFLSales with an interface class and an implementation class. Both the interface and the implementation class have COM and GUID attributes.
Interface Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;
namespace CRUFLSales
{
[ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual), Guid("4D06968D-043F-447E-9AFB-8C3BD767A366")]
public interface IAudit
{
//Audit Class methods Signatures
long Method_1(string param1);
}
}
Implementation Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Windows.Forms;
using System.Data;
namespace CRUFLSales
{
[ComVisible(true), ClassInterface(ClassInterfaceType.None), Guid("F448164C-6223-4067-BC53-7E9F4FB9DE13")]
public class Audit : IAudit
{
public Method_1(string param1)
{
//Method code here..…
}
}
}
We also checked the option “Register for COM Interop” in Build Tab and checked the option “Make COM Visible” in Assembly Information tab. Build Platform is x86 (32-bit). Used a Strong key name in the Signing tab and generated DLL.
After generating the DLL, we followed the below steps to register the DLL.
Copied the DLL to C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86 and using Visual Studio Command Prompt – ran gacutil -i <<dll name>>
Copied the DLL to C:\Windows\Microsoft.NET\Framework\v4.0.30319 and ran RegAsm.exe <<dll name>> to register as 32 bit UFL.
I could see the DLL is registered at C:\Windows\Microsoft.NET\assembly\GAC_32 .
After that, when I went into CR designer, opened a report and went into Formula editor screen – I don’t see the methods of my UFL inside Additional Functions. I do not see any folder for u212com.dll at all.
Opened Visual Studio 2012, Visual Studio Command Prompt and CR2013 with administrator privileges.
Software Versions
MS Visual Studio 2012 (.net framework 4.5)
DLL generated and deployed in Windows 7 (64 bit OS).
Crystal Reports 2013
Can someone let us know where we might have gone wrong? Thanks in Advance for your help!
Hi Raghu,
To use the UFL in CR Designer you need to read a little more....
The KBA - 1525014 - Sample C# .NET UFL and Localization Formula function
at the bottom there is a link to create a C++ UFL, that KBA has some more info so I update the COM KBA above with the same info which is:
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.
Thank you
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Don, The solution worked out and I am able to see the method in Additional Functions. However, I ran into one more problem of a similar kind.
I wrote a new UFL with methods AB and XY. I need to see this methods in Additional functions.. These methods execute an Oracle query. I have written a separate class for Oracle connection. This connection class has 2 methods. One to get oracle connection object and another to execute the Oracle query. I created an object for this connection class and used it in my methods AB and XY to get connection object and execute query. I did not give any GUID and COM Visible properties for the Connection class. I followed the process, build dll and deployed. I did not see AB and XY methods in Additional Functions in designer.. Later, I added the GUID and COM Visible properties and built and deployed the DLL. Still no luck..
Am I doing something wrong here?. Thanks in advance for your help!
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.