HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

G

Guest

HOWTO Make a C# UserContol Memory Map to a C++/MFC/EXE

Please help,

I have a UserControl that I want to have "talk" to a C++/MFC/EXE program
that is already running via a memory map.

The C++/MFC/EXE app is using the traditional WIN32 commands like

OpenFileMapping
MapViewOfFile
UnmapViewOfFile

And others.

Put another way, the C++/MFC/EXE is using plain/jain Memory Map Techniques,
where the memory map has a "known" name, and any application can access the
memory map in the same "Desktop".

I am not sure which C#/.NET functionality I should use. I see the
MemoryStream class, but I see no reference to it being "compatible" to Memory
Maps.

Please advise.
 
N

Nicholas Paldino [.NET/C# MVP]

ATS,

The MemoryStream class is just a class that will allow you to get
stream-semantics while using a byte array as the back-end store. It has
nothing to do with memory maps.

If you want to use memory maps, you will have to make a call to the same
API calls through the P/Invoke layer.

You could wrap it up in a Stream-based class if you want, and then
read/write back and forth.

Hope this helps.
 
G

Guest

Thanks Nicholas for the reply,

So, there is no .NET/C# equivalent for Memory Maps at all?
 
G

Guest

I put together a caching mechanism using memory-mapped files and had the
opportunity to try out three or four different implementations in .NET. The
best and most reliable one I found was a freeware offering called
"MetalWrench ToolBox", which is unfortunately no longer "findable" on the
net. However, there is a copy of it in the download that accompanies this
article that I wrote about it:

http://www.eggheadcafe.com/articles/20050116.asp

Peter
 
G

Guest

Thanks for the reply,

That is a big dissapointment that .NET does not support Memory Mapped Files.
The excuse of scrapping all code features for the cause of "managed code" is
obviously the reasoning behind not supporting Memory Mapped Files, and it is
a poor excuse. Interprocess communnication with Memory Map Files is a valid
and highly needed software development technique.
 
G

Guest

There are lots of Windows API's that aren't built in to the .NET platform.
That's what the P/Invoke layer is for.
Cheers,
Peter
 
N

Nicholas Paldino [.NET/C# MVP]

ATS,

Actually, I wouldn't think that is the case. I think security is a
bigger reason why there are no memory mapped file implementations.
 

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