0

Possible Duplicate:
Create a C# DLL That Can Be Imported in a Delphi App Using stdcall - Possible?

I am creating a c# library and like to make this library as com component which can be accessed from delphi. Please tell the how to achieve this.

Community
  • 1
  • 1
Partha
  • 2,062
  • 6
  • 24
  • 31
  • 3
    duplicate of http://stackoverflow.com/questions/1063151/create-a-c-dll-that-can-be-imported-in-a-delphi-app-using-stdcall-possible/1063231#1063231 (and probably many others) – devio Jul 13 '09 at 06:52

3 Answers3

3

How to make .Net (C#) classes accessible through COM is described here. Basicly your classes need to have a default constructor without parameters and you need to decorate your classes with some specific attributes. Then you need to register your assembly using regasm.

Then you can import the ActiveX/COM library in Delphi and call it like it was a regular ActiveX/COM Library.

Martin Schneider
  • 14,263
  • 7
  • 55
  • 58
Lars Truijens
  • 42,837
  • 6
  • 126
  • 143
0

I won't rewrite, but there is a solution on how to do this here : http://forums.devshed.com/delphi-programming-90/c-dll-need-to-be-used-in-delphi-231122.html

Amadeus45
  • 1,228
  • 2
  • 17
  • 28
0

If you aren't opposed to using VB instead of C# there's a cleaner solution. In VB you can use the ComClass item template which does virtually all the work to expose your .NET type to COM for you.

Rob Windsor
  • 6,744
  • 1
  • 21
  • 26