通过在Delphi COM对象有时会挂起使用.NET类 [英] Using .Net classes through COM Objects in Delphi sometimes hangs

查看:218
本文介绍了通过在Delphi COM对象有时会挂起使用.NET类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组,我想在我的Win32(德尔福)的应用程序使用写在Delphi.NET(.NET 1.1)库。对于性能相关的问题,我已经决定要遵循COM路线。

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.

有时候,重建DLL后,当我试图通过实例化COM公开的对象的Win32应用程序挂在CreateComObject电话 - 我怎么能解决这个问题。

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?

要暴露通过COM的Delphi.NET库,我想补充上述各班减速以下属性:

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

[标记有​​ComVisible特性(真) [的Guid(一些GUID')] [ClassInterface(ClassInterfaceType.AutoDual)]

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

编译DLL后,我产生一个* TLB.pas文件,该文件包含定义所有的公共和COM可见的类和接口的DLL,这个文件可以让我更方便地使用COM对象在我的德尔福Win32应用程序。最后,我使用regasm注册DLL和.TLB flie。

After compiling the DLL, I generate a *TLB.pas file, this file contains definition for all public and COM visible classes and interfaces in 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.

我试着取消注册和运行的Win32应用程序。它引用的DLL文件;我希望收到运行时错误,但应用程序再次挂在CreateComObject电话。

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

我也试着注销和注册DLL没有任何的运气。

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

感谢。

P.S。我使用BDS2006

p.s. I am using BDS2006

推荐答案

我还混有COM经验; COM有时可以是一个真正的痛苦,以获得稳定的,因此,如果没有必要,我经常带anoter路线。

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.

在这种情况下,你可以尝试使用反P / Invoke来绕过去COM。

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.$c$cgear.com/ timjarvis / 2006/11 /二万九千二百七十〇分之一十 http://www.blong.com/Conferences/BorConUK2002/Interop1/Win32AndDotNetInterop.htm http://www.blong.com/Conferences/BorCon2004/Interop1/Win32AndDotNetInterop.htm

您可以得到更多的点击,当你在谷歌德尔福反PInvoke的但上面的人是最好的文章。

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

亲切的问候,

吉荣Pluimers

Jeroen Pluimers

这篇关于通过在Delphi COM对象有时会挂起使用.NET类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆