Use string type for a Visual Studio (V100 toolset) project

Hi,
I'm using Visual Studio 2010 Professional - yes, quite old, but I am obliged to use it. The build toolset is marked as V100.
I create a C++ empty project, with, for the beginning, just <Windows.h> to include. It was supposed that I then add the necessary libraries files so that to make the code buildable.
Just for info, the scope of the project is to create a dll and call it in C#. Everything goes fine with one exception, and I didn't find the solution: it's about the 'string' type. If I define as 'string' a variable in C++ it is not recognized. I have tried with 'using namespace std;' but got the error that 'std' is not recognized either.
I have used 'char *' instead and it works when marshalling to C#. The need to use 'string' appears when I want to export a C++ class to C# and the C++ constructor called in C# must instantiate a 'string'. I've tried all kinds of C# and C++ methods and functions, I'm not happy with the result or the complexity.
Therefore, how can I, for the given development environment - VS2010, C++, empty project - have access to a 'string' type?
Thanks
You have to include <string> before using namespace std;

The need to use 'string' appears when I want to export a C++ class to C# and the C++ constructor called in C# must instantiate a 'string'.


Why can't the constructor take a char* ?
Why don't you use a dll project in VS ?
Why don't you use C++/CLI , it would be much easier to use in C# ?

Sorry for being so curious, but it seems you make your live more difficult than neccessery.
Thanks Thomas,
I've solved my issue which was in fact related to marshalling an alphanumeric variable from C++ to C#, and did it through a C# IntPtr container. My initial assumptions where wrong, in fact using char* in C++ is the best by far.
Topic archived. No new replies allowed.