Skip to main content
10 events
when toggle format what by license comment
Mar 10, 2020 at 8:49 comment added Voo @Benedict If you're relying on the GC for cleanup in this case, that's exactly your problem. The correct approach is to use IDisposable. The challenge as always with C++ code is to make sure you get the ownership right (generally you want a C# object to own the native code/objects and encapsulate all its functionality).
Mar 9, 2020 at 19:14 comment added 17 of 26 At my last company, we had a C++ MFC application that was over a million lines of code. I was able to replace the MFC UI with C#/WPF and successfully re-use over 90% of the C++ code. In order to mix the deterministic nature of C++ destructors with the non-deterministic nature of garbage collection, you just need to make extensive use of IDisposable.
Mar 9, 2020 at 16:44 comment added Benedict @T. Sar If it's a really simple interface that the OP wants (1 function call returning data), then yes, a network interface is overkill.
Mar 9, 2020 at 16:44 comment added Benedict @JonasH I'm not saying there can't be proper dispose/finalize handling - I've said it's "hard to ensure". The main issue is that the GC is not-deterministic in when it destructs and in what order.
Mar 9, 2020 at 16:44 comment added Benedict @Cubic Indeed. You can use a simpler network protocol of course. Having a backend process be a webserver (also offering diagnostic pages) is just a nice way of building an application, accepting overhead. The point is to use a network solution instead of linkage.
Mar 9, 2020 at 15:53 comment added T. Sar Ideally, the C++/CLI part should do little more than solder the bits between the two different environments. If you're using a solid API that is well tested and stable, I don't see how any of this could be a problem.
Mar 9, 2020 at 15:21 comment added Cubic Why websocket as opposed to just regular TCP? Seems needlessly roundabout to have HTTP on top if all you need is a stream anyway.
Mar 9, 2020 at 15:16 comment added asr9 having done a similar project in the past (& burned myself), I would recommend the same. Debugging managed & unmanaged code was one of the problems we suffered.
Mar 9, 2020 at 15:04 comment added JonasH I am curious about the problems you have encountered. If the .Net wrapper owns the c++ object and has proper dispose/finalize handling, there should not be any risk of accessing disposed c++ objects, right?
Mar 9, 2020 at 14:33 history answered Benedict CC BY-SA 4.0