I have source code for Delphi application. I need to access the methods in the Delphi source from a C# application. My actual requirement is to create C# wrapper class on Delphi methods, So that I can call it from dot net application. Can you please help me to write C# wrapper on Delphi code?
Hydra from RemObjects might be a solution to your problem (i haven't tried it):
http://www.remobjects.com/hydra/
Hydra makes it possible to use native Delphi methods in a .NET application and use .NET methods in af Delphi application.
I have did that by creating Web service from Delphi and call it from c#.
another solution to write Delphi Com DLL and use it in C#.
Related
i'm exploring the idea of use .net as a scripting language for my program.
i found a lot of examples on internet that shows how to host .net and then, from c++ call functions from .net.
But i need to go on the other way too, from this code in c#, i need to be able to create/call c++'s objects from this c# script, so i need to expose functions/objects to control it from C#.
How can i do it?
Simple Example to show what i'm talking about
I call my c++ method "CreateGUI". It'll call .net code: "InitializeGUI", and this "InitializeGUI" need to check if an object (for example, the texture) is instantiated inside C++.
Can someone help me?
Thanks!
If you use managed C++, you can create a managed C++ component which can be called from your C# code. If you use unmanaged C++, you can either create a C++ COM component and use it through C# via RCW (Runtime Callable Wrapper) mechanism or you can create a C++ dll and call it from C# via PInvoke.
You might also investigate Mono, which is explicitly intended to be embedded and will run any compiled .NET assembly, meaning the full powers of C#, VB.NET, even F# will be available.
I'm building a metro application where I need to call call a C# lib from C++. Simply calling the C# code wasn't hard. The problem is how I should communicate back from C# to C++. How do I do this in winRT? Is it possible? Because all the examples I've found only have a one way communication.
Ok, it actually was really simple. I could implement a C# interface in my C++ code which I could use as a callback from the C# lib.
I am wondering if there is something like automatic conversion/wrapper code generation of a c++ API to C#?
Specifically I am seeking a way to call the Remote Desktop Services API from C#.
A suggestion: C++/CLI.
Using the C++/CLI you can use the libraries written in C/C++ to C/C++ along with of the .net libraries/dll's. More information:
A first look at C++/CLI
No you definitely need to create an interop code.
If it's a COM api there is some sort of support for using it directly with C#
You might try either decompiling RDCMan (http://www.microsoft.com/download/en/details.aspx?id=21101), it does it. Or there is an open source project on Codeplex that does it as well.
http://terminals.codeplex.com/
EDIT:
There is also a tool that Microsoft provides call aximp (http://msdn.microsoft.com/en-us/library/8ccdh774(v=VS.100).aspx). If you run aximp.exe {{path_to}}\mstscax.dll, it will generate a .NET WinForms control library that wraps the ActiveX control.
In my project I got a device which comes with C++ Sample codes. The codes are ok and the device is working as expected.
But I need it to talk with my C# interface because all other devices are currently using C# interface.
So I am planning to create a DLL Wrapper for the driver. I will create a C++ Library of my own (from source code with proper interface) and Call this C++ Library from C# using DLLImport (just call my interfaces there.).
I am pretty sure it can be done this way, but I have never created a C++ Library and used it from C# yet. So, can anyone refer me to some tutorial that goes with my problem?
I am using C++/C# int VS.NET 2008.
Regards,
Maksud
Have a look at
using a class defined in a c++ dll in c# code
Another useful tool you have at your disposal is C++ CLI.
You can use C++ CLI to create an intermediate library - one that exposes managed classes but runs unmanaged C++ code. You can actually mix managed and unmanaged C++ in the same DLL.
The unmanaged portion can accesses the unmanaged DLLs without having to use the PInvoke functions.
Your C# code can access the managed classes in this intermediate library.
Depending on the DLL and what you need to do you may not need to create a wrapper directly. You might be able to get away with P/Invoke for the functions. You will need to evaluate your specific needs and what is already available in the libraries/code provided.
For anyone who comes to this question and are looking for answers, you may want to try xInterop NGen++ , a C# wrapper generator for native C++ DLL, which has been just released to the public, the tool can generate C# wrapper for native C++ DLL automatically and instantly by using advanced P/Invoke technologies. Check out the current version and a free version will be out soon.
(I am the author of the tool)
I have a C# class library that contains methods that need to be used with an external application. Unfortunately this external application only supports external APIs in C/C++.
Suppose I have a takeIntReturnDoubleArray method in this C# library that takes an integer and returns an array of doubles. All I need to do is have a C++ method that takes an integer, calls the C# library and returns an array of doubles to the calling application.
So in essence the C++ library is just acting as an intermediary between the C# wrapper and the external application.
Is there an easy way to do this? Do I have to do anything special on the C# side to allow it to be imported into C++ easily? I have seen some talk of using the #import statement but I really have no idea what I am doing when it comes to C++.
What is the approach I should be taking here?
You have two main options here:
C++\CLI - this allows you to have both managed and unmanaged code in the same source file. The managed portion can then call the C# code.
COM Interop - expose your .NET type as a COM interface and matching coclass which you can easily use from unmanaged C++.
COM Interop is one way to approach this problem. You'll have to have a COM layer for the C# library function(s) you want to expose to the C++ application. This (http://msdn.microsoft.com/en-us/library/aa302324.aspx#usingframeworktools_topic10) might be of interest.