Click here to Skip to main content
15,884,978 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello my dear friends.

I have a .dll file that a class named 'Class1' is in it. Class1 contains a method named 'Convert' that it is a type of Public Static String with a decimal input parameter.

In my project I use crystal report for reporting. In my report I want to use this method ( 'Convert' ) of Class1.

Please tell me how can I do it.

Thanks a lot.
Posted
Updated 10-Aug-12 7:44am
v2
Comments
Nueman 10-Aug-12 13:48pm    
No capitalization. Sorry, my OCD kicked in.
Sergey Alexandrovich Kryukov 10-Aug-12 14:07pm    
And what is the problem? Use it? What don't you know? How to add a reference? How to use the class, name it? What?
--SA
HOSSEIN.AB 12-Aug-12 6:17am    
I want to use my method (Convert) in a formula field in my report with call it.
is this possible?

This highly depends on the version you're using, but custom functions are located in a User Function Library (UFL) in Crystal terms. One tutorial to start with: Creating a User Function Library[^]
 
Share this answer
 
Comments
HOSSEIN.AB 12-Aug-12 6:21am    
thank you
for use ufl i must write my code again,i just want to call my method 'convert' in the report and use it without writing my code twice or more.
Wendelius 12-Aug-12 6:35am    
Since Crystal expects the methods to be 'published' in the described way, I believe that you must write an UFL. However, I don't see why you would need to write the code twice. Just create the UFL and from that library, call your actual convert method in some library (add reference in the UFL project to your own library containing the convert).

So the idea for the UFL in this case would be to just pass the call forward to your existing methof and then return the result.

Hopefully that makes sense.
HOSSEIN.AB 13-Aug-12 4:20am    
OK.
thank you for your help.
i read this link Creating a User Function Library
and add my assembly to Global Assembly Cache (GAC) and find it in the C:\Windows\assembly path but when i try to use my method in formula field in the crystal report ,i can't see my class or my function in the Functions\Additional Functions to use it.
what i must do? ( i must add reference to .dll file in my project? or any other things? )
I use Windows 7 and Visual Studio 2008
Wendelius 13-Aug-12 6:09am    
It's quite hard to say without seeing the whole situation, but perhaps there's something wrong with the COM interop registration. Have you defined the GUID, defined the IExchangeUfl interface and defined the method in yhe interface and so on?
HOSSEIN.AB 17-Aug-12 12:52pm    
yes .
i defined the IExchangeUfl interface and it's method. but i named my interface 'IConvertUFL' instead 'IExchangeUfl'.
is it a wrong or no?
really , in This link ,i can't understand the 'Note' section and ignore it.
this might be my problem?
this is my project's link to download it. Click here
Hello,

I have the same problem described in this thread. I am trying this on Visual Studio 2010 with Crystal Reports 13 (for VS.NET). I have done all the steps as described in tutorial:

http://msdn.microsoft.com/en-US/library/ms227661(v=vs.80)[^]

Also in this ebook, page 390:

VS2005_Walkthroughs.pdf[^]

However my class and functions are not showing up in Crystal Reports Designer (Formula Workshop > Functions > Additional Functions). I verified that my DLL, named CRUFLICE.DLL, is registered with COM. I have an older VB6 DLL which, if I register it with COM, then it's functions do show up. So I renamed my VB.NET class, methods, assembly, to match the old DLL and still no luck. I would do C# but the new .NET custom functions are going to replace the old VB6 custom functions, so I am doing it in VB.NET so can reuse some of the old code.

My new DLL is 8 letters long starting with CRUFL prefix. My class is ComVisible and has a Guid and implements an interface. My functions are public and return a String. I have registered DLL through Visual Studio build option and directly with regasm and gacutil. What else am I missing?

Thanks.
 
Share this answer
 
Comments
italotech 22-Jan-14 15:08pm    
OK, I figured it out. More information here:

http://scn.sap.com/community/crystal-reports-for-visual-studio/blog/2009/05/22/creating-crystal-reports-user-function-libraries-ufl-with-visual-studio-net

What I was missing is that my .NET project was building as Any CPU (default). I changed it to build as x86 then rebuild it then register DLL with COM and GAC. Then close Visual Studio and reopen it. Now it shows up in Functions > Additional Functions > COM and .NET UFLs (u212com.dll)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900