Solved

How can use a .NET dll under Delphi win32?

Posted on 2014-12-24
7
383 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
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 26

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
3 Use Cases for Connected Systems

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

 
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 26

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

12 Experts available now in Live!

Get 1:1 Help Now