error
-
error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(
ozgul wrote: How can solve this problem? By showing us the code in context.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(
I'm not familiar with the managed extension ... did you try copying the C buffer of the std::string ? something like : std::string s; yourSystemStringVariable = s.c_str();
Maximilien Lincourt Your Head A Splode - Strong Bad
-
ozgul wrote: How can solve this problem? By showing us the code in context.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
My code is; #include "stdafx.h" #include "SysInfo.h" #using #using using namespace System; using namespace System::Data; using namespace System::Net; using namespace System::IO; using namespace System::Text; using namespace std; int _tmain() { SysInfo sysInfo = new SysInfo(); String* uriString; String* postData; uriString = "http://localhost/WebApplication3/WebForm1.aspx"; WebClient* myWebClient = new WebClient(); myWebClient->Headers->Add(S"Content-Type", S"application/x-www-form-urlencoded"); //postData = Convert::ToString(sysInfo.getCpuModel()); postData = sysInfo.getComputerName(); Byte byteArray[] = Encoding::ASCII->GetBytes(postData); Byte responseArray[] = myWebClient->UploadData(uriString, S"POST", byteArray); Console::WriteLine(S"\nResponse received was {0}", Encoding::ASCII->GetString(responseArray)); }
-
error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(
-
My code is; #include "stdafx.h" #include "SysInfo.h" #using #using using namespace System; using namespace System::Data; using namespace System::Net; using namespace System::IO; using namespace System::Text; using namespace std; int _tmain() { SysInfo sysInfo = new SysInfo(); String* uriString; String* postData; uriString = "http://localhost/WebApplication3/WebForm1.aspx"; WebClient* myWebClient = new WebClient(); myWebClient->Headers->Add(S"Content-Type", S"application/x-www-form-urlencoded"); //postData = Convert::ToString(sysInfo.getCpuModel()); postData = sysInfo.getComputerName(); Byte byteArray[] = Encoding::ASCII->GetBytes(postData); Byte responseArray[] = myWebClient->UploadData(uriString, S"POST", byteArray); Console::WriteLine(S"\nResponse received was {0}", Encoding::ASCII->GetString(responseArray)); }
i don't for your answer, but i'd like to give some advices. ozgul wrote: using namespace System; using namespace System::Data; using namespace System::Net; using namespace System::IO; using namespace System::Text; if you are
using System::
, you don't have tousing
parts of it... you can so delete the 4 lines following. ozgul wrote: uriString = "http://localhost/WebApplication3/WebForm1.aspx"; in general, we are talking aboutURL
s, notURI
s. at last, where does your code crash (about what line) ???
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
My code is; #include "stdafx.h" #include "SysInfo.h" #using #using using namespace System; using namespace System::Data; using namespace System::Net; using namespace System::IO; using namespace System::Text; using namespace std; int _tmain() { SysInfo sysInfo = new SysInfo(); String* uriString; String* postData; uriString = "http://localhost/WebApplication3/WebForm1.aspx"; WebClient* myWebClient = new WebClient(); myWebClient->Headers->Add(S"Content-Type", S"application/x-www-form-urlencoded"); //postData = Convert::ToString(sysInfo.getCpuModel()); postData = sysInfo.getComputerName(); Byte byteArray[] = Encoding::ASCII->GetBytes(postData); Byte responseArray[] = myWebClient->UploadData(uriString, S"POST", byteArray); Console::WriteLine(S"\nResponse received was {0}", Encoding::ASCII->GetString(responseArray)); }
I assume you have a problem with the following line!
postData = sysInfo.getComputerName();
Is this correct!? Everything else looks fine IMO. You should change it to readpostData = sysInfo.getComputerName().c_str();
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
visibly, you are trying to assign a string* with a string. didn't you forget the address operator (
**&**
) ?
TOXCCT >>> GEII power
[toxcct][VisualCalc]