I have a class in C++ and I am sure I have something declared wrong. public ref class foobar { public: String^ GetString() { return(gcnew String("null")); } } Of course the real code is a little more complex, but not much. This crashes the program in "release" mode, but works fine in "debug" mode. Which made it very difficult to track down. What am I doing wrong? thanks -- Darryl Wagoner DE WA1GON Want a scholarship into the Millionaire Mind Intensive worth $2590? http://www.secretsofthemillionairemind.com/a/?wid=603891 Crash programs fail because they operate under the theory that nine pregnant women can deliver one baby in one month. -Werner von Braun --------------= Posted using GrabIt =---------------- ------= Binary Usenet downloading made easy =--------- -= Get GrabIt for free from http://www.shemes.com/ =- ** Posted from http://www.teranews.com **
Those symptoms imply that it's being GC'd. Debug mode GC behaves differently (mainly so you can see debug values and not have them disappear on you). As soon as you new it, it's disappearing, probably because of the interop layer and no references to the string. The conventional thing to do IMO is to have te client pass a StringBuilder and have the C++ put data in there. If you look at pinvoke.net and all the Win32 Dll calls that's a common model for strings. -- Phil Wilson "Darryl Wagoner" wrote in message news:89bc1$48590816$23972@news.teranews.com... >I have a class in C++ and I am sure I have something declared wrong. > > public ref class foobar > { > public: > > String^ GetString() > { > return(gcnew String("null")); > } > } > > Of course the real code is a little more complex, but not much. > This crashes the program in "release" mode, but works fine in > "debug" mode. Which made it very difficult to track down. > > What am I doing wrong? > > thanks > > -- > > Darryl Wagoner > DE WA1GON > > Want a scholarship into the Millionaire Mind Intensive worth $2590? > http://www.secretsofthemillionairemind.com/a/?wid=603891 > > Crash programs fail because they operate under the theory > that nine pregnant women can deliver one baby in one month. > -Werner von Braun > > > --------------= Posted using GrabIt =---------------- > ------= Binary Usenet downloading made easy =--------- > -= Get GrabIt for free from http://www.shemes.com/ =- > > ** Posted from http://www.teranews.com **