Search code examples
.netunmanagedmanaged-c++managed-codemixed-mode

My application is unmanaged. Where do I start introducing managed code?


My whole application (which is rather big, with a 20MB executable) is written in unmanaged C++. Because I can clearly see the advantages in using managed code, I want to start introducing managed code in my application, but where do I start?

Can I easily start to use C++/CLI and link it with the rest of my application? (although the C++/CLI syntax seems rather 'exotic').

Or is it better to move to C#, but what is the best way to 'link' this together with my unmanaged C++ code?

Does it make sense to compile all my C++ code with the /clr option? Will this work?

Do I have to worry about marshalling? Does this give an overhead or can I switch between managed and unmanaged without a performance penalty (just as I did 20 years ago when mixing fortran and C). Performance is really important in my application since it is a scientific application that sometimes processes several Gigabytes of memory.

Or does it only make sense to redesign the user interface, and only write this in C#, and keep the rest of my application (calculation logic, business logic, database interface, ...) in unmanaged C++?

Since my application sometimes needs to handle several Gigabytes of memory, I have a 64-bit variant. Is it easy to have 64-bit managed code? Woudl the garbage collector be still efficient if that much memory is used?

Simply state: where do I start?

Patrick


Solution

  • For the moment, consider this question closed.

    I realized that the answer is not mixing C++ and C#, but getting the architecture right in the first place.

    If the architecture is correct, and separated where it needs to be separated, than changing parts of the application by other modules (external, other language, ...) should be easier.

    Regarding the performance problems during marshalling, we will have to wait until .Net has further matured.