views:

145

answers:

2

Hi Guys,
Is it OK/possible to have a shared memory in a COM object which will be consumed by applications built using C# and/or C++?
Can C# access shared memory in COM object without crash?

Thanks,
Adi Barda

+1  A: 

Yes it is you need -- all you need to do is create a memory mapped file. If you can't do this in .NET directly, you need to do it in C/C++ code which you embed and call from your .NET application.

Making it crash proof requires understanding the underlying subtleties properly, for that boost::interprocess might help as it abstracts these quite well.

Hassan Syed
A: 

I don't really see what role the COM object plays in this. But, no, there isn't anything that makes MMFs fundamentally incompatible with managed code. They are merely very awkward to use since you need pointers to access them.

Support for MMFs is coming in .NET 4.0. It is probably too soon to use that in production code. But do make sure to take a look at the API so that what you do now is going to fit the API well when you switch.

Hans Passant