Solved

How can use a .NET dll under Delphi win32?

Posted on 2014-12-24
7
365 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
7 Comments
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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 25

Expert Comment

by:Sinisa Vuk
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
Comment Utility
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 25

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 250 total points
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now