Jump to content
  • Advertisement
  • entries
    437
  • comments
    1000
  • views
    336847

C++ / CLI and managed wrappers

Sign in to follow this  
evolutional

243 views

I'm at a complete loss. I want to store a pointer to a managed object within an unmanged class (perhaps as an int, or void *, whatever) and then cast it back to the managed class at a later date. I simply don't have a bleeding clue how though.
Sign in to follow this  


2 Comments


Recommended Comments

This is very similar to the problems you can get using Boost Smart Pointers, for instance if a class internaly needs to return a representation of itself, all it knows is 'this' however you want it returned as a shared_ptr, but you cant just 'divine' the appropriate shared_ptr object.

the problem is, while you can go from managed to unmanaged, you cant go from unmanaged to managed, unless you build infrastructure to facilitate the join.

i've found it best to design around it if you can, otherwise, baring some special tricks youll need an association table i think.

Share this comment


Link to comment
The Marshal class a lot of magic in it. Might be what you're looking for. Usually you just have to deal with IntPtr's but I'm not entirely sure how that's translated into C++/CLI.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!