Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can use a .NET dll under Delphi win32?

Posted on 2014-12-24
7
Medium Priority
?
521 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 28

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 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 28

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 1000 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 38

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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