Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error

error

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ozgul
    wrote on last edited by
    #1

    error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(

    D M T 3 Replies Last reply
    0
    • O ozgul

      error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      O 1 Reply Last reply
      0
      • O ozgul

        error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • D David Crow

          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

          O Offline
          O Offline
          ozgul
          wrote on last edited by
          #4

          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)); }

          T A 2 Replies Last reply
          0
          • O ozgul

            error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *' How can solve this problem? Please help me:(

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            visibly, you are trying to assign a string* with a string. didn't you forget the address operator (**&**) ?


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            O 1 Reply Last reply
            0
            • O ozgul

              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)); }

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              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 to using parts of it... you can so delete the 4 lines following. ozgul wrote: uriString = "http://localhost/WebApplication3/WebForm1.aspx"; in general, we are talking about URLs, not URIs. at last, where does your code crash (about what line) ???


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

              1 Reply Last reply
              0
              • O ozgul

                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)); }

                A Offline
                A Offline
                Antony M Kancidrowski
                wrote on last edited by
                #7

                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 read postData = 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)

                1 Reply Last reply
                0
                • T toxcct

                  visibly, you are trying to assign a string* with a string. didn't you forget the address operator (**&**) ?


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  O Offline
                  O Offline
                  ozgul
                  wrote on last edited by
                  #8

                  A lot of thanks.... I changed this line postData = sysInfo.getComputerName(); with postData = sysInfo.getComputerName().c_str(); Then it worked very well. Again thanks every body...

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups