4

I need to pass data between a vb6 app and a .net app. This data will either be written or read every second. It is about 30 fields. Both apps reside on the same machine. I am currently passing this data via the registry and it works great but it makes me a little nervous. I would do it with a text file but I am worried about data loss.

What is the best way to do this?

jocoder
  • 85
  • 8
  • 2
    Pretty scary. This is not something the registry was intended for. Ever hear of registry hive fragmentation? – Bob77 Jan 27 '12 at 20:57

4 Answers4

2

I'd recommend using some sort of RPC process to share the information if you want to do this easily.

The easiest one would probably be XML-RPC

VB6 and .Net seem to both have the necessary libraries.

You could also connect to the same database if you're worried about data loss.

Moox
  • 1,122
  • 9
  • 23
1

Common back end? Yes, the registry works, text file will work, but in a multi-user environment, you're better off with a database (MS Access or SQL Server, for example.)

Beth
  • 9,531
  • 1
  • 24
  • 43
  • 1
    +1. SQL Server probably better in a multi-process environment. Maybe [SQL Server Compact](http://stackoverflow.com/questions/416716/would-you-use-sql-server-compact-for-a-desktop-application) – MarkJ Jan 27 '12 at 20:58
  • 1
    A database is probably the most expensive form of IPC there is. – Bob77 Jan 27 '12 at 21:03
  • OK, expensive, yes, especially if you have to hire a DBA, but it will handle multi-user updates better than the registry or a text file. – Beth Jan 27 '12 at 21:04
  • SQL server seems like extreme overkill when a simple file will do. – JohnFx Jan 27 '12 at 21:16
  • Yeah, I agree, Access is cheaper. Depends on how big the problem is. We have a Teradata server out here... – Beth Jan 27 '12 at 21:19
  • I was thinking that with a database you have the same need to poll for changes as with a file, but you also have a lot more disk, memory, and raw cycles consumed - and probably that much more code to maintain. Throw in a "lily of the field," er DBA, and things get that much worse. – Bob77 Jan 27 '12 at 22:18
  • I rewrote the 2 apps to use a mdb file that is created. I have a remote sql db that the vb6 was writing to. The reason for this post is I want to break that link and write to the db with a .net app. – jocoder Jan 30 '12 at 16:18
1

Actually Mailslots work fine between machines too. Though they don't work well for messages much over 400 bytes.

DDE is still supported too, and is quite fast. Probably no .Net support however.

And of course simple out-of-process COM is just a thin layer on top of Windows RPC.

Bob77
  • 13,167
  • 1
  • 29
  • 37
  • I thought about DDE too. It was the go-to answer back in the VB6 days and I'll bet there is some .NET code out there to make that work. – JohnFx Jan 27 '12 at 21:17
  • But there are caveats and it isn't R. Chen's favorite thing: http://blogs.msdn.com/b/oldnewthing/archive/2007/02/26/1763683.aspx – Bob77 Jan 27 '12 at 21:31
  • @Bob: "Mailslots work fine between machines too" - generally it does, but receipt of the message isn't guarenteed. – rskar Jan 27 '12 at 21:32
  • That's a valid point, and the same can be said of UDP datagrams. Luckily in this case his processes are on one machine so that won't trouble him. – Bob77 Jan 27 '12 at 22:11
  • I already tried Ndde. The dde server on kept locking up and the only way to free it up was to reboot. – jocoder Jan 30 '12 at 19:32
  • The Raymond Chen link above suggests that .Net doesn't have DDE support anyway. Was "Ndde" a typo? NetDDE is something else, and that definately lost support a while ago - though I thought I read that some 3rd party still offers a solution. – Bob77 Jan 30 '12 at 20:24
0

Pick your poison: Mailslots, Memory-mapped files, Named Pipes, Sockets. There's plenty of help and code on the web for these.

Small messages between processes on the same machine (both Windows OS): Go with MailSlots.

Large blocks of data between processes on the same machine: Go with Memory-mapped files.

Streaming messages between processes (same or different machines, both Windows OS): Go with Named Pipes.

Streaming messages between processes (same or different machines, same or different OS's): Go with Sockets.


Since you're using the registry now, maybe Mailslots instead.

rskar
  • 4,607
  • 25
  • 21
  • @jocoder: There are two places to check out. First, a C# project at http://www.codeproject.com/Articles/19231/Fully-functional-Asynchronous-Mailslot-Control-in – rskar Jan 30 '12 at 22:12
  • @jocoder: Second, this is someone's VB code, mostly works (tho he had an issue with it): http://forums.devx.com/archive/index.php/t-160327.html – rskar Jan 30 '12 at 22:13