Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling .net 4.0 built dll in Delphi 7

After searching and applying all solutions for below problem, are not working. What I have done- 1. I created a .dll in C#, made its com visible ture. 2. I creadted the .tlb using regasm. 3. Created a Delphi 7 project where I imported this type library (.tlb) and calling the function of this dll. 4. All is running fine on my PC.

Now when I copied these all files (including .dll, even .dcu too) to another PC (.Net framework 4.5 installed) and tried to run the .exe, it gives me error "Class not registered", when I tried registering it with RegSvr32 then it shows error -"Entry point not found".

What else am I missing? Is there any other prerequisite to run Delphi 7 exe with dll on another PC?

like image 883
Prateek Shukla Avatar asked Jan 07 '23 01:01

Prateek Shukla


1 Answers

To register a .net assembly you must use regasm and not regsvr32.

Making the entire assembly COM visible is probably a mistake. Do you really want to make all public type COM visible? It would be more usual to apply the ComVisible attribute to specific types.

You don't need to copy dcu files. These are used as intermediate files for the Delphi compiler. Assuming you aren't using runtime packages, just the executable, and the registered assembly should suffice.

like image 93
David Heffernan Avatar answered Jan 12 '23 09:01

David Heffernan