Jump to content
  • Advertisement
  • entries
  • comments
  • views

C++ / CLI and managed wrappers

Sign in to follow this  


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  


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!