4

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?

Prateek Shukla
  • 593
  • 2
  • 7
  • 27

1 Answers1

9

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I didn't find regasm.exe on the other PC where I am getting this problem. I intentionally made com visible true. – Prateek Shukla Dec 08 '15 at 06:24
  • Where did you look? If the machine has .net installed it should be there. All public type are COM compatible? Really? – David Heffernan Dec 08 '15 at 06:33
  • I found it at - C:\Windows\Microsoft.NET\Framework\v2.0.50727, when I tried to register from it, I got error that the dll is not a valid .net assembly. – Prateek Shukla Dec 08 '15 at 06:40
  • That's the .net v2 regasm no? You need the v4.0 version surely? – David Heffernan Dec 08 '15 at 06:44
  • Yes I did with v4.0 too, I got message "type registered successfully", but again when I ran the application, getting the same error "Class not registered". Sorry for posting the path of v2.0 that I tried before posting this question. – Prateek Shukla Dec 08 '15 at 06:51
  • You need to use 32 bit regasm not 64 bit regasm: http://stackoverflow.com/questions/24451812/how-to-do-regasm-so-that-it-cover-32-bit-and-64-bit – David Heffernan Dec 08 '15 at 06:52
  • Yes, It worked for me. Put is as answer so that I up cast the same. Thanks. Just want to know that My OS is of 64-bit, then wh I need to register it with 32 bit regasm? – Prateek Shukla Dec 08 '15 at 07:03
  • 4
    I think I already answered the question. You need the 32 bit regasm since the host exe is 32 bit. – David Heffernan Dec 08 '15 at 07:04