Introduction to RPC on Windows, Part II - Types of Binding Handles
(Page 3 of 5 )
Before we use any binding handles let’s take a look at their various types and when to use each one. Binding handles are of three types:
- Automatic
- Implicit
- Explicit
You must decide which one of these to use based on the amount of control you need to have over the binding process or the process of creating a logical connection.
Automatic binding handles
Automatic binding handles really automate the binding process and you don’t have any control over this process whatsoever. The good news is that the client and server applications do not need to publish any code to handle the binding process. One may use these handles when the application does not require a specific server and when it does not need to maintain any state information between the client and server. To use Automatic binding in your applications you need to specify that you will use automatic binding handles in the application Configuration File (ACF). The code for the generated stub by the MIDL Compiler then contains the code for managing automatic binding. A typical ACF file for automatic handles looks like the one below:
/* ACF file */
[
auto_handle
]
interface MyInterface
{
// Any Methods
}
So what happens when the ACF does not include any other handle attribute, and when the remote procedures do not use explicit handles; how would binding would occur? It’s simple -- the MIDL compiler uses automatic handles by default. The same things happen when the ACF file is not present. One more thing to be aware of is that you must not provide an auto handle as an argument to any of the remote procedures declared in your interface. A Sample IDL would look like the one below:
/* IDL file */
[
uuid (6B29FC33-CA47-1067-B31D-00DD010662DA),
version(1.0),
pointer_default(unique)
]
interface IFoo
{
void GetRange([out] long * min);
void Shutdown([in] long * nAfterStep);
}
Next: Implicit binding handles >>
More .NET Articles
More By Digvijay Chauhan