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. Use of managed variables in non-ref class

Use of managed variables in non-ref class

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

    Hi, I am currently working on extending an existing C++ project with new functions. The existing project is made using C++, without using managed variables. I would like to insert some of my function which I have written in C++/CLI, so with managed variables. Is it possible to declare a managed variable within a class, without making the class a ref class? If I have to make it a ref class it produces a load of errors, as it is connected with parts of existing code that cannot deal with that. Any ideas would be more than welcome! Thanks, Arjen

    N S 2 Replies Last reply
    0
    • K KlaasVersteeg

      Hi, I am currently working on extending an existing C++ project with new functions. The existing project is made using C++, without using managed variables. I would like to insert some of my function which I have written in C++/CLI, so with managed variables. Is it possible to declare a managed variable within a class, without making the class a ref class? If I have to make it a ref class it produces a load of errors, as it is connected with parts of existing code that cannot deal with that. Any ideas would be more than welcome! Thanks, Arjen

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Arjen Tjallema wrote:

      Is it possible to declare a managed variable within a class, without making the class a ref class? If I have to make it a ref class it produces a load of errors, as it is connected with parts of existing code that cannot deal with that. Any ideas would be more than welcome!

      Yes, you can. You need to use a gcroot. See http://msdn.microsoft.com/en-us/library/481fa11f(VS.80).aspx[^]

      Regards, Nish


      Blog: blog.voidnish.com

      1 Reply Last reply
      0
      • K KlaasVersteeg

        Hi, I am currently working on extending an existing C++ project with new functions. The existing project is made using C++, without using managed variables. I would like to insert some of my function which I have written in C++/CLI, so with managed variables. Is it possible to declare a managed variable within a class, without making the class a ref class? If I have to make it a ref class it produces a load of errors, as it is connected with parts of existing code that cannot deal with that. Any ideas would be more than welcome! Thanks, Arjen

        S Offline
        S Offline
        slawomir_orlowski
        wrote on last edited by
        #3

        It is possible to recompile native code as managed code. You can build wrapper class to expose unmanaged C++ code in CLI. Then you can use managed infrastructure in your code. Check G. Hogenson "C++/CLI" book.

        K 1 Reply Last reply
        0
        • S slawomir_orlowski

          It is possible to recompile native code as managed code. You can build wrapper class to expose unmanaged C++ code in CLI. Then you can use managed infrastructure in your code. Check G. Hogenson "C++/CLI" book.

          K Offline
          K Offline
          KlaasVersteeg
          wrote on last edited by
          #4

          Thanks a lot, I'll go find out more about it. Regards, Arjen

          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