2
votes

I have a set of libraries written in Delphi.NET (.NET 1.1) which I want to use in my Win32 (Delphi) application. For performance related issues, I've decided to follow the COM route.

Sometimes, after rebuilding the DLL, when I try to instantiate the objects exposed through COM, the Win32 application hangs at the CreateComObject call. How can I solve this problem?

To expose the Delphi.NET libraries through COM, I add the following attributes above each class deceleration:

[Comvisible(true)] 
[Guid('some guid')] 
[ClassInterface(ClassInterfaceType.AutoDual)] 

After compiling the DLL, I generate a TLB.pas file, this file contains definitions for all public and COM visible classes and interfaces in the DLL. This file allows me to more easily use the COM objects in my Delphi Win32 application. Finally, I register the .dll and the .tlb flie using regasm.

I've tried unregistering and running the Win32 app, which references the DLL; I expected to receive a run-time error, but the application once again hung at the CreateComObject() call.

I've also tried unregistering and registering the DLL without any luck.

p.s. I am using BDS 2006

3
It just hangs? No CPU? No error? Never returns?Lars Truijens
yes, it never returns from the call, also the CPU usage isn't pegged.The Alchemist
does it happened in other langs? C++ OR VB/VBScript?Baget
To isolate the problem I instantiated the com object using Ruby and it worked! but, I need to make this work with Dephi 2007 (Win32) P.S. I'm decorating the classes w/the ComVisible attribute individually instead of the entire assembly, will this make a difference?The Alchemist

3 Answers

1
votes

I have mixed experiences with COM; COM can sometimes be a real pain to get stable, so if not needed, I often take anoter route.

In this case, you could try to go around COM by using inverse P/Invoke.

Here are a few articles that can help you on this:

http://blogs.codegear.com/timjarvis/2006/11/10/29270 http://www.blong.com/Conferences/BorConUK2002/Interop1/Win32AndDotNetInterop.htm http://www.blong.com/Conferences/BorCon2004/Interop1/Win32AndDotNetInterop.htm

You can gets more hits when you google on "Delphi Inverse PInvoke" but the above ones are the best articles.

Kind regards,

Jeroen Pluimers

0
votes

Be sure that you shut down the code in a proper manner, and do not just stop it in the debugger. I've found that killing inter-process applications using the debugger can cause all sorts of problems, usually needing a reboot to clear them away. It takes discipline to do this as normally you can do it without problem.

0
votes

Using RemObjects Hydra is an easy way to mix managed and unmanaged Delphi code. But unfortunatly it's quite expensive - $499 :(

Update: try Delphi.Net open source project. This project is inactive, but you can use it for Win32 -> dotNet1.1 assembly interaction.