Reputation:
So I am new to .net and c++ and am in need of a "library" of functions that can be called and also events that are raised in the main application that is using the library.
I have a C++ library (.lib) that I want to add another layer (wrapper) on top of it and only expose a few functions and events for the main application. I don't know which app technology to use : C#, VB.net, or CLR Winform (Dont know if that is the right name).
What am I looking to do? What should I be searching for on Google?
I imagine I should be looking to make a DLL (but what kind? I have seen C, C++, and .net C++)
Do I expose a C++ class? But how do I raise events? Virtual Functions I believe right?
Do I create some kind of object that the application references to have events/functions?
As you can see I am new to this technology and a newb in this area.
Thank you
Upvotes: 1
Views: 387
Reputation: 6076
So given that you have already written a c/c++ DLL, and now want to write a GUI which uses it, here are my suggestions:
On item #2, my personal suggestion, assuming your DLL has more than a few functions, is to write a managed c++ DLL. Here is a fairly basic, but good tutorial, it essentially comes down to compiling the DLL as managed code, and writing a wrapper class/es to allow other .net apps access to the unmanaged functions/classes.
Upvotes: 1
Reputation: 11287
Woah :)
..CLR Winform..
You mean C++/CLI ?
Well .. It all depends on which language you wan't to use your wrapper with. A .dll can be many different things, implementation-wise, but they all have something in common: They got data which you can use from other applications. That data being methods, classes, public integers, whatever :)
If you want to use your facade in C++, then write the .dll in C++. If you want to use it from .Net, write it in any .Net language you want, using P/Invoke, or use C++/CLI - But beware of the hundreds of pitfalls there is when doing stuff cross-language. .Net uses a garbage collector, C++ doesn't (by default :) You could ofc use something like Boost pointers or the likes to get a "GC-feeling".). You don't mention which IDE you're planning to use or which O/S you're targetting. A .dll in windows is different than one in Linux for example.
Bottom-line: It depends on your target language, O/S and for easiness of writing the facade, the IDE :)
Good luck with it.
Visual studio: C++ dll, .Net dll, native C++ to .Net wrapper using C++/CLI
Upvotes: 0