3
String* response_Page="";
std::string http_Response;

//WinHttp Request
//http_Response append (pszOutBuffer);

response_Page = gcnew System::String(respstring);

I am trying to create a managed C++/CLI dll to be used in c#, new to C++, it is really complex, cant get much info just by searching.

Update: I am using Common Language Runtime Support, Old Syntax (/clr:oldSyntax)

Getting error: error C2065: 'gcnew' : undeclared identifier

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Milan Solanki
  • 1,207
  • 4
  • 25
  • 48

2 Answers2

4

The error is caused by using new style managed C++ syntax with the /clr:oldSyntax compiler option. Either use old style syntax or use new style syntax and don't use the oldSyntax flag.

The only reason to use the oldSyntax flag is if you're maintaining legacy code. Other than that one reason, avoid the old syntax, it was yucky.

Skizz
  • 69,698
  • 10
  • 71
  • 108
  • Is it possible to create managed dll that can be used in c# in New Style Syntax – Milan Solanki Aug 02 '11 at 08:50
  • @Milan: Yes, it is certainly possible. Don't forget that the version of the .Net run time needs to be compatible between the DLL and the application. – Skizz Aug 02 '11 at 09:01
1

You need to use ^ instead of * to use gcnew. If you need an unmanaged pointer then use * with new

String^ response_Page="";

Also, there are lots of C++/CLI books out there; you should consider getting one. eBook format available. http://manning.com/ and http://www.apress.com/

  • C++/CLI in Action (Manning)
  • C++/CLI The Visual C++ Language for .NET (Apress)
  • Pro Visual C++/CLI and the .NET 2.0 Platform (Apress)
  • Expert Visual C++/CLI: .NET for Visual C++ Programmers (Apress)
  • Foundations of C++/CLI: The Visual C++ Language for .NET 3.5 (Apress)
  • Pro Visual C++/CLI and the .NET 3.5 Platform (Apress)
Carlos Quintanilla
  • 12,937
  • 3
  • 22
  • 25