Solved

How can use a .NET dll under Delphi win32?

Posted on 2014-12-24
7
419 Views
Last Modified: 2015-05-17
Hello,

I'd like to use a .NET dll under Delphi win32. This dll contains different classes, methods and events. I'd like to use all of them under Delphi in similar way. For example if there is a class TestClass with methods Start and Stop and with method OnStart, then I'd like to use this class under Delphi with the same name, methods, properties and events.

Thank you in advance for your help!
0
Comment
Question by:ForExpert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 40
ID: 40517426
The dll must have been compiled with special attributes, so that it can be registered on the users station to be usable by COM applications such as the classic version of Delphi.

If it was not, then you cannot use it.

If it was compiled to be COMVisible, then you should be able to use it as you do with the dlls that you are used to work with.
0
 
LVL 27

Expert Comment

by:Sinisa Vuk
ID: 40519709
There is an article ... Using a .NET Assembly via COM by Jim McKeeth with more information's. There is a tool that might help you: Managed extensions for VCL
0
 

Author Comment

by:ForExpert
ID: 40519989
Thank you for your answers!

Fortunately there are at least 2 3rd-party solutions to do this without modification: Atozed CrossTalk and RemObjects Hydra. But I'd like to use a native, direct solution.
Managed extensions for VCL can't handle .NET3.5, .NET 4.0 and above. It is useful for 2.0 only.
Could you show me a small example?
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 40520100
The first issue that you should look at is what I told you in my previous post, also stated more plainly in the second link from Sinisa:

Managed VCL can not:
•Query .Net interface if it is not COM visible.

If the libraries that you want to use were not compiled to be used with COM, there is nothing you can do, unless you have the source code and recompile them with the proper attribute. And this is true for any tool you might try to use to bridge the gap. It would be like asking for a horse to work on gas. Unless the gas has been loaded with grass, there is nothing in the gas to feed the horse. Unless the .NET library has been compiled to expose itself to COM, there is nothing for your COM application to chew on.

Ask your library provider if the dll is COM compatible. If yes then you should be able to connect to it as you do with any other COM dll, with possible problems in type translations. If not, find another library.

You can easily put a vinyl record on a cassette type and then on a CD or MP3 with only a cable in between. But try to do the reverse. The same apply here. Microsoft has defined a way for .NET to make itself visible to COM. But in my experience dealing with hundreds of .NET programmers, very few of them care to add the 2 lines necessary to do so in their .NET projects.
0
 
LVL 27

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 250 total points
ID: 40520575
Another solution will be another com compatible dll which will expose (COM visible) methods but internally use .net dll from third party. This is a "bridge" to that dll. This dll should be build in C# .net and requires some knowledge for that. You can ask someone to build it.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 40781529
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question