Managed code and Legacy C++ RRS feed

  • Question

  • We are currently converting some code over to C# however we have legacy code written in C++/C that will not be converted. In our legacy there are tons of instance where we used char*, string, and std::string. In these instance sometimes we get errors in debug when code is trying to cleanup the strings. It seems like it doesnt know which destructor to use. We are now seeing other areas in Release mode that are doing the same thing but are ok in debug. When I see these errors I have been changing the string types to std::string and it seems to clean everything up...Maybe because it is very specific to which destructor to use?

    Here is an overview of our arch...

    C# (new code) -> Managed C++ (legacy wrapper) -> C++ (Legacy). The legacy wrapper interacts with one project in legacy that has the project setting /clr set. Could this be causing some of the problems?

    These errors are really concerning and keep popping up. I fix one and another pops up a couple days later. I really really dont want to have to go back into legacy and change all the strings to std::string, this would be disasterous.

    Thank you in advance.

    Tuesday, July 15, 2008 6:22 PM


  • Can you provide a little more information?  Here are a few things:

    Who is freeing the memory, when, and how?
    How are you marshaling the data? A example would be nice.
    What type of calling convention are you using?

    The destructor reference in terms of the types you mention is throwing me for loop, not quite understanding what you mean.  It almost sounds like memory for the strings is being allocated on the stack, but you would see a read write protected memory exception if that were the case.
    • Marked as answer by jack 321 Monday, July 21, 2008 3:10 AM
    Tuesday, July 15, 2008 8:18 PM