Solved

How can use a .NET dll under Delphi win32?

Posted on 2014-12-24
7
439 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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