Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

There is a 3rd party SDK based on .NET technology which I want to use in Borland C++. What's the best way to use .NET in Borland C++?

Regards
Posted
Comments
Richard MacCutchan 3-Sep-13 9:27am    
Ask the people who wrote the SDK.

This is not so easy. First of all, I would think about using migrating to .NET or using something else. However, the problem is solvable.
Please see my past answers:
loading C# DLL in MFC[^],
How can I use a dll created in Visual Basic 2008 in Visual Basic 6.0[^],
Call Managed DLL written in C# from Unmanged Code VC++[^],
API's in .Net: Managed or UnManaged Code[^].

—SA
 
Share this answer
 
Comments
sid2x 4-Sep-13 6:56am    
5/5!
Sergey Alexandrovich Kryukov 4-Sep-13 12:08pm    
Thank you.
—SA
Member 3832831 5-Sep-13 5:15am    
Thank you Sergey!

Very interesting links. From one of your links I ended up on this article by Nick Parker: http://www.codeproject.com/Articles/3511/Exposing-NET-Components-to-COM
which is a solution of my issue. Once again, thank you for your time!
Sergey Alexandrovich Kryukov 5-Sep-13 10:45am    
You are very welcome.
Good luck, call again.
—SA
To what I think Borland C++ is a very old and outdated compiler (what I think), MingW and Cygwin easily beat Borland, as you can see on the Wikipedia Page Borland's last stable release was in 1999
Now to your question :
You are trying to Link to extremely different things together, which in fact is possible, but will be extremely tough as SA said.
A google hit on
using c# dll in c++ (Note that those people might use Other C++/C Compilers)
gave me this :
http://www.cplusplus.com/forum/windows/77244/[^]
And here's some info from this thread http://stackoverflow.com/questions/3799907/using-c-sharp-dll-in-project-c[^]
2.2 How do I call .NET assembly from native Visual C++?

There are basically four methods to call .NET assembly from native VC++ code. Microsoft All-In-One Code Framework has working examples that demonstrate the methods.

Native VC++ module calls CLR Hosting APIs to host CLR, load and call the .NET assembly. (All-In-One Code Framework Sample Code: CppHostCLR)

If the .NET assembly can be exposed as a COM component, native VC++ module can call into the .NET assembly through .NET – COM interop. (All-In-One Code Framework Sample Code: CppCOMClient)

Reverse PInvoke: the managed code call native passing a delegate the native code can call back. (All-In-One Code Framework Sample Code: CSPInvokeDll)

If the module containing native VC++ code is allowed to enable CLR, the native VC++ code can call .NET assembly directly through the "It Just Works", or "IJW", mechanism. (All-In-One Code Framework Sample Code: CppCLIWrapLib)

Also you can use SWIG (Simplified Wrapper and Interface Generator)
http://www.swig.org/[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Sep-13 12:14pm    
Interesting links, but I think they are still don't cover the most fundamental method described in the CodeProject articles. The idea is: 1) CLI standards actually allow exporting methods from an assembly as unmanaged, 2) such methods could be specified in IL code, 3) it can be automated via diassembling code (with methods to be exported as unmanaged marked with a special attribute), and re-assembling it.

I voted 4.
—SA
sid2x 5-Sep-13 4:32am    
Yes, CLR/CLI is required for interaction between .NET and unmanaged code, But I was thinking about the program, will it require the .NET Framework if he calls the .NET Dll, from a C/C++ Program,......
Member 3832831 5-Sep-13 5:18am    
I agree with Sergey. Very interesting links! Thank you for the tips!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900