Managed c++ std::string not accessible in unmanaged c++
- by Radhesham
In unmanaged c++ dll i have a function which takes constant std::string as argument
Prototype : void read ( const std::string &imageSpec_ )
I call this function from managed c++ dll by passing a std::string.
When i debug the unmanaged c++ code the parameter imageSpec_ shows the value correctly but does not allow me to copy that value in other variable.
imageSpec_.copy( sFilename, 4052 );
It shows length of imageSpec_ as 0(zero).
If i try copying like std::string sTempFileName(imageSpec_); this statement string new string is a empty string.
But for std::string sTempFileName(imageSpec_.c_str()); this statement string gets copied correctly. i.e. with charpointer string is copied correctly.
Copying this way will need a major change in unmanaged c++ code.
I am building unmanaged code in Visual studio 6.0 and managed c++ in Visual studio 2008.
Is there any specific setting or code change in managed c++ that will solve the issue?