Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using C# DLL in Delphi

1,654 views
Skip to first unread message

OB

unread,
Jul 18, 2002, 2:12:30 PM7/18/02
to
Does anyone know how to use C# DLL in Delphi program?

thanks


Chris R. Timmons

unread,
Jul 18, 2002, 2:51:46 PM7/18/02
to
"OB" <ob55...@yahoo.com> wrote in news:3d37048f_2@dnews:

> Does anyone know how to use C# DLL in Delphi program?

OB,

You have to use .NET to "wrap" the C# code as a COM object. Then
your Delphi code can use it like any other COM object. There's a
great article showing how to do this in this month's Delphi
Informant (you have to be a subscriber to access the article,
however):

http://www.delphizine.com/

There is also a lot of non-Delphi related information on how to do
this on MSDN:

http://msdn.microsoft.com/

Search for "com interop". This should return a list of articles
to get you stared.

HTH,

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

OB

unread,
Jul 18, 2002, 6:47:24 PM7/18/02
to
Thanks Chris, that helps alot.

"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xns924F8D06CB946cr...@207.105.83.65...

OB

unread,
Jul 19, 2002, 12:55:47 PM7/19/02
to
Here what you do in order to use .NET DLL in Delphi:
In order to use a C# DLL in Delphi you must compile C# DLL as COM object 1st
then reference the com object in DLL

Try to do the following in C#. before compiling the dll project, right click
on the project name, click on configuration properties, click on build and
set

"Register for COM interop" to TRUE.

Compile the DLL

Let's assume the DLL name is: C#DLL, and the class name within the DLL is:
C#Class And the class has an "ADD" function that you want to call and pass
it two params: 45 , 33 and finally the return value is an integer

Then in Delphi, do the following:

// Assign object reference to variable

OleObj = CreateOLEObject('C#DLL.C#Class');


//call the ADD function found in the C# DLL

ShowMEssage(InttoStr(OleObj.Add(45, 33)));

Omar Bondogji

"OB" <ob55...@yahoo.com> wrote in message news:3d37048f_2@dnews...

0 new messages