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. Using magaged C++ class in unmanaged class data member.

Using magaged C++ class in unmanaged class data member.

Scheduled Pinned Locked Moved Managed C++/CLI
helpc++
3 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.
  • M Offline
    M Offline
    Murlai
    wrote on last edited by
    #1

    I am new to the Managed C++,I have created a namespace "N" with one "Cl" class in that name space. Now I want to use this "Cl" as a data memeber in a unmanaged C++ class. the syntax i have followed in Unmanaged c++ class header is as follows.. class Unmanged { public: Cl *m_Managed; }; The reported error is.. error C3265: cannot declare a managed 'm_Managed' in an unmanaged 'Unmanaged' Please help in solving this is very urget for my assignement.. Thanks.

    U N 2 Replies Last reply
    0
    • M Murlai

      I am new to the Managed C++,I have created a namespace "N" with one "Cl" class in that name space. Now I want to use this "Cl" as a data memeber in a unmanaged C++ class. the syntax i have followed in Unmanaged c++ class header is as follows.. class Unmanged { public: Cl *m_Managed; }; The reported error is.. error C3265: cannot declare a managed 'm_Managed' in an unmanaged 'Unmanaged' Please help in solving this is very urget for my assignement.. Thanks.

      U Offline
      U Offline
      ursus zeta
      wrote on last edited by
      #2

      Are both of these classes in the same application? Is the unmanaged class a COM object? At any rate, when you transfer data to and from managed and unmanaged types or call functions again from managed to unmanaged, or from unmanaged to managed classes or objects, the Interop marshaler takes care of some operations (invisibly from the programmer's point of view). Generally, this involves some data transfer and the marshaler tries to convert defined types to their compatible types in the other domain. The marshaler, because it deals with so many different and disparate types has a well-designed behavior. User-defined types are the most difficult to deal with and sometimes it is necessary to write a custom marshaler to enable the Interop to work properly. There is lots of information over at the MSDN site. And, in all honesty, I am not that experienced in this area, but, it is common to experience problems with Interop. I have been reading: "NET and COM: The Complete Interoperability Guide", by Adam Nathan, and I would highly recommend it as a source of 'official' Interop intel. A simple suggestion, though: use the same types for your data in both managed and unmanaged classes, and re-write your functions so that they accept those data members, rather than the class.

      1 Reply Last reply
      0
      • M Murlai

        I am new to the Managed C++,I have created a namespace "N" with one "Cl" class in that name space. Now I want to use this "Cl" as a data memeber in a unmanaged C++ class. the syntax i have followed in Unmanaged c++ class header is as follows.. class Unmanged { public: Cl *m_Managed; }; The reported error is.. error C3265: cannot declare a managed 'm_Managed' in an unmanaged 'Unmanaged' Please help in solving this is very urget for my assignement.. Thanks.

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        Google for gcroot.


        My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

        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