开发者

Wrapping a c#/WPF GUI around c++/cli around native c++

开发者 https://www.devze.com 2023-03-13 17:39 出处:网络
This is kind of a complicated situation. I\'m refactoring (ground-up) c++ that must be used as both a CGI script and the core of a standalone app.

This is kind of a complicated situation. I'm refactoring (ground-up) c++ that must be used as both a CGI script and the core of a standalone app.

Unfortunately I haven't written C++ since college, and am more familiar with c#/Java. So I'm going to use WPF for the GUI. From what my research has revealed, this means that I will be:

1) Refactoring the base code in unmanaged C++ (yay for intellisense support, eh?)

2) Wrapping that base in a managed class library

3) Wrapping step 2 in a C#/WPF GUI, referencing it through interop (CLI/CLR).

step 2, I am confident, will be well-documented. However, I'm starting at the top and can't find anything concrete on how to instantiate and use a class created/exposed in managed c++.

I'd just write the whole thing in c# if I had my druthers (no need for hardcore efficiency), but I don't have that choice.

Can someone point me in the right direction for step 3 so that I can start researching it? I don't want anyone to do my homework for me (so to speak), but my own r开发者_开发技巧esearch into this process has been fruitless.


If you wrap your unmanaged C++ classes in managed CLI / C++ objects, then you don't need Interop to invoke the managed classes (Visual C++ will compile both managed and unmanaged C++ in the same library).

Simply reference the mixed managed / unmanaged library to your managed C# application and the exposed managed objects will behave like any normal object.

For a good starting point check out this article.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号