Visual Basic .NET/Interprocess Communication< Visual Basic .NET
Generally, each program in Windows has its own virtual memory space. In other words, one program cannot change variables in another program. Marshalling is the process of passing data and memory addresses between applications. There are several ways different programs can communicate with each other.
This is a 'roll your own' solution. Both applications access files in a shared directory, reading and writing data from them to communicate. The simplest method is for the sending application to write a separate file for each message and the receiving application to delete those files once processed. The sending application should create the file with exclusive access so the receiving application cannot access a half-written file. There should also be a mechanism for re-synchronising if one or the other application is shut down during a conversation.
The main downside of this approach is that the receiving application must poll the shared directory at regular intervals (e.g. by using a Timer control). This generates harddisk/network traffic, and the polling interval limits the responsiveness of the conversation.
This method consists of overriding the WndProc method in a Form to receive, and the PostMessage Win32 API call to send a custom Windows message.
This method has the advantage of easily accommodating both communication between programs on the same computer, and programs on different computers in the same network (or even across the internet). It uses the System.Runtime.Remoting namespace, which you can add via Project References.
These methods are not used much anymore, but may be encountered if you are trying to communicate with a legacy application.
Dynamic Data Exchange was the original method Windows used for programs to communicate with each other. It is still used by Windows for "Cut and Paste".
Object Linking and Embedding
Common Object Model.
- Reference counting
- Late binding via IDispatch
ActiveX EXEs and DLLs