C++ / CLI and managed wrappers

Published March 27, 2006
Advertisement
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.
Previous Entry C# .NET
Next Entry Aussies
0 likes 2 comments

Comments

EDI
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.

March 27, 2006 03:22 PM
Rob Loach
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.
March 27, 2006 07:32 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement