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.
Related
I am working on a basic 2D C++ Game engine but i want to be able to use C# to make games with it like unity does but I'm not sure how to do it. I've seen people saying about CLI but not sure exactly how that works. I want to be able to access functions on the engine in C# and be able to have the engine run the C# code.
Thanks for any help with this.
Right now you have two big ways of doing this:
Make your C# application generate COM objects which you can consume from C++. Performance is a bit iffy, but doable and very simple.
Use reverse PInvoke, where you export functions from your C++ application with in function pointers that you fill in from the C# side with delegates to the functions that drive your code.
In .Net 5, there's a third way: you can directly export C# functions from your assemblies to be consumed in a platform-independent way, like in C++ (ie, .dll or .so exports).
I want to call native C++ code from a windows phone 8.1 project. I was going off this How do I call C++/CLI from C#? for a while up until I found out that I can't reference a C++/CLI library in my windows phone project... too bad, because that would've been very convenient.
How ought I go about this?
You can also use Platform Invoke. It's much lighter weight, but you should be pretty comfortable about translating the definitions in the header files to .NET types. And don't even bother trying straight C++--it's doable but really messy. Wrap it in a C API and dynamically bind that.
https://msdn.microsoft.com/en-us/library/26thfadc(v=vs.110).aspx
i am working on a RFID based project in which we should communicate with Gates(RFID tag reader is called a GATE) through our application (and we are using java 2 ee to do this). the problem is the Gates are only shipping with c# and c++ SDK.
what is your solution to communicate between c++ / C# and java? is there any so called convertor that can ease the pain?
and this is the Gates manufacturer website if you need any more info : http://www.marktrace.com/en/default.html
thank you all.
You are searching for the Java native interface which allows you to communicate with other libraries.
You can either call methods from an external DLL and call Java methods from within your C++ code.
You can use jni4net to have a bridge to .NET libraries as well.
Besides using the JNI that the other answers mention, I was writing a similar program for collage and we just wrote a C# client that talked to the library then bridged the gap to java by writing a simple TCP server in C# that the main java app talked to.
JNI - Java Native Interface - You can use it to call C++ code from Java.
http://docs.oracle.com/javase/6/docs/technotes/guides/jni/
Here is a tutorial.
Java Native Interface is what you need. There are also couple of alternatives and specific libs
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 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#.