My application is built in two sections. A C# executable which is the front end UI and a C++ dll which is more the low-level stuff. My application creates and manages many instances of objects, where every C++ object instance has a corresponding C# object instance. What techniques or libraries can I use to ensure that objects in the C# and C++ sections and data in those objects are always in sync at runtime? A change of one member in one object instance should update the corresponding object instance.
Thanks!
Edit: clarified a little what I meant by keeping the objects in “sync”
It’s not quite clear whether it would solve the problem, but have you considered Managed C++? I have had pretty good success simply compiling my C++ code as Managed C++, then using the managed extensions to create .NET classes that use the underlying C++ data directly. That way, there’s only one copy of the data.
Probably not suitable for every situation (and I haven’t tested its limits by any means) but I found it quite a timesaver. And since Managed C++ is a proper .NET language, the result was clean to use from the C# side, with none of the usual oddities or quirks one often has to work around when trying this sort of thing.
(Another similar approach would be to use SWIG (http://www.swig.org/) to generate wrappers for you. I hear it is easy to use and works well, but I haven’t used it myself.)