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. Managed C++/CLI
  4. CString to System::String + MFC Q

CString to System::String + MFC Q

Scheduled Pinned Locked Moved Managed C++/CLI
c++csharphelp
4 Posts 3 Posters 1 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.
  • E Offline
    E Offline
    eladbo
    wrote on last edited by
    #1

    Hi, I am trying to write a very simple application that mixes MFC with C++ Managed. I have two questions: 1. Is it possible to build the mixed project with the MFC library statically linked. I get some errors of conflict which I don't get when building with dynamically linked. 2. I want to use .NET functions that ask for System::String^ str. When I supply these functions with CString I get error. I read every where that it suppose to work. CString str = _T("Works"); CString str2 = _T("Doesn't Work"); String ^ stringEx = gcnew String( str ); // OK :) strinEx = str2; // Is not working :omg: Thanks. -- modified at 4:32 Thursday 20th April, 2006 eladbo

    A M E 3 Replies Last reply
    0
    • E eladbo

      Hi, I am trying to write a very simple application that mixes MFC with C++ Managed. I have two questions: 1. Is it possible to build the mixed project with the MFC library statically linked. I get some errors of conflict which I don't get when building with dynamically linked. 2. I want to use .NET functions that ask for System::String^ str. When I supply these functions with CString I get error. I read every where that it suppose to work. CString str = _T("Works"); CString str2 = _T("Doesn't Work"); String ^ stringEx = gcnew String( str ); // OK :) strinEx = str2; // Is not working :omg: Thanks. -- modified at 4:32 Thursday 20th April, 2006 eladbo

      A Offline
      A Offline
      ariaci
      wrote on last edited by
      #2

      Hi, You cannot assign an CString object to a string. Every string assignment in .NET creates a new string on the garbage collector and recycles the old one. There is no global defined assignment operator for this available :(. You could try to write: strinEx = gcnew String(str); This makes no difference to the other assignment.

      1 Reply Last reply
      0
      • E eladbo

        Hi, I am trying to write a very simple application that mixes MFC with C++ Managed. I have two questions: 1. Is it possible to build the mixed project with the MFC library statically linked. I get some errors of conflict which I don't get when building with dynamically linked. 2. I want to use .NET functions that ask for System::String^ str. When I supply these functions with CString I get error. I read every where that it suppose to work. CString str = _T("Works"); CString str2 = _T("Doesn't Work"); String ^ stringEx = gcnew String( str ); // OK :) strinEx = str2; // Is not working :omg: Thanks. -- modified at 4:32 Thursday 20th April, 2006 eladbo

        M Offline
        M Offline
        Maksim Libenson
        wrote on last edited by
        #3

        Hi, The answer to the first question is probably that it is impossible to do static linking since the code produced for managed application is not native binary code but MSIL. For different string conversions check following article: http://msdn2.microsoft.com/en-us/library/ms235631.aspx Max

        1 Reply Last reply
        0
        • E eladbo

          Hi, I am trying to write a very simple application that mixes MFC with C++ Managed. I have two questions: 1. Is it possible to build the mixed project with the MFC library statically linked. I get some errors of conflict which I don't get when building with dynamically linked. 2. I want to use .NET functions that ask for System::String^ str. When I supply these functions with CString I get error. I read every where that it suppose to work. CString str = _T("Works"); CString str2 = _T("Doesn't Work"); String ^ stringEx = gcnew String( str ); // OK :) strinEx = str2; // Is not working :omg: Thanks. -- modified at 4:32 Thursday 20th April, 2006 eladbo

          E Offline
          E Offline
          eladbo
          wrote on last edited by
          #4

          Thanks for the information :) eladbo.

          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