sharing unmanaged object across managed borders

D

DaTurk

Hi,

I'm trying to have a unmanaged object contatined in a a managed
class. THis is no problem, but I need access to this object in other
managed classes. I'm not sure how to do this. I mean, it wouldn't
really make sense to be able to pass in a unmanaged object into a
managed anything because it can be accessed via C#. Any help would be
appreciated.

Thank you in advance.
 
B

Ben Voigt

DaTurk said:
Hi,

I'm trying to have a unmanaged object contatined in a a managed
class. THis is no problem, but I need access to this object in other
managed classes. I'm not sure how to do this. I mean, it wouldn't
really make sense to be able to pass in a unmanaged object into a
managed anything because it can be accessed via C#. Any help would be
appreciated.

You can surely put pointers to unmanaged classes in a ref class, and declare
these as internal visibility so your other classes in the same assembly can
use them.

For access from outside the assembly, providing properties on the containing
ref class is probably the best approach. You may want to add an extra ref
class that does nothing other than wrap around the unmanaged data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top