I nead to pass an Interface from the C++ wrapper into a C# class
-
Folks.. I have created a wrapper project that exports two procedures that I pick up in my Win32 program created in something called Clarion for Windows. The wrapper class calls my C# objects and this works just fine. Problem is that my C# program neads different calls back to my Clarion Win32 program. For instance, my Win32 program has a function to generate new Customer ID's and the complexity of this routine is to much. Becides, I would really like to know if there is a way to do this. The connection between Clarion Win32 and C++ is by using a standard interface decleared in Clarion and passed into the exported function in C++. Problem is that I dont know how to call back to C++ Hers what I have: Clarion(Win32) <=> C++ => C# So Clarion can call C++ methods directly through the Interface, and therfor implicit Clarion can call .NET methods through this wrapper. But I nead the other way too. I was hoping I could pass an Interface from C++ into my C# objects, maybe something like this: MyNetClass::TakeCppInterface(ThisCppInterface); I have posted on the MSDN, but only answer I got there was using MSIL or reflection, which i think is way over my head at the moment.
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
-
Folks.. I have created a wrapper project that exports two procedures that I pick up in my Win32 program created in something called Clarion for Windows. The wrapper class calls my C# objects and this works just fine. Problem is that my C# program neads different calls back to my Clarion Win32 program. For instance, my Win32 program has a function to generate new Customer ID's and the complexity of this routine is to much. Becides, I would really like to know if there is a way to do this. The connection between Clarion Win32 and C++ is by using a standard interface decleared in Clarion and passed into the exported function in C++. Problem is that I dont know how to call back to C++ Hers what I have: Clarion(Win32) <=> C++ => C# So Clarion can call C++ methods directly through the Interface, and therfor implicit Clarion can call .NET methods through this wrapper. But I nead the other way too. I was hoping I could pass an Interface from C++ into my C# objects, maybe something like this: MyNetClass::TakeCppInterface(ThisCppInterface); I have posted on the MSDN, but only answer I got there was using MSIL or reflection, which i think is way over my head at the moment.
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
You can use a C++/CLI wrapper instead of C++ wrapper so that C++/CLI wrapper can use directly in C#
-
You can use a C++/CLI wrapper instead of C++ wrapper so that C++/CLI wrapper can use directly in C#
Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
-
Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
can you provide a code snippet
-
Well, isnt that what I allready do ;-) I nead to call back to C++ from the C# Her's the flow: Clarion(Win32) Calls C++ method. C++ then calls C# method. C# Method calls C++ Method. C++ Method Calls Clarion(Win32) Method now, Clarion and C++ can comunisafe over an Interface C++ and C# communicates through a class But what can I use to communicate C# to C++ ?
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
Well the solution depends on the dependencies between DLL. Assuming that Clarion is using a DLL with C++/CLI code and that DLL is using a C# DLL, then you would also define an interface in C# DLL that will be implementend by C++ code when calling back into C++. Delegates or events could also be used in some cases. This is particulary interesting if for each C# method, you already know which (single) method would be called during processing.
Philippe Mori
-
Well the solution depends on the dependencies between DLL. Assuming that Clarion is using a DLL with C++/CLI code and that DLL is using a C# DLL, then you would also define an interface in C# DLL that will be implementend by C++ code when calling back into C++. Delegates or events could also be used in some cases. This is particulary interesting if for each C# method, you already know which (single) method would be called during processing.
Philippe Mori
Yes. This is what I had in mind.. But I'm not sure how to implement a C# interface in C++. As far as I know, the C# Interface is not C++ compatible becasue C++ actually dont have interfaces (i'm a noob in C++ so this statement is based on things I have read etc.)
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
-
Yes. This is what I had in mind.. But I'm not sure how to implement a C# interface in C++. As far as I know, the C# Interface is not C++ compatible becasue C++ actually dont have interfaces (i'm a noob in C++ so this statement is based on things I have read etc.)
----------------------------- Speaking nordic language? Why not visiting irc.c-c.no and join #C# or #VisualBasic -----------------------------
To implement the interface just derive from it as you would do in C#.
Philippe Mori
-
To implement the interface just derive from it as you would do in C#.
Philippe Mori
I wil take this under consideration If I reopen the project. As by now, the whole thing is done using a .NET EXE and parameters
----------------------------- Ole Morten Heien HD Software / Advisor AS -----------------------------