Contexts and Remoting

Recall that the context forms a .NET Remoting boundary around object instances within it. Figure 6-1 illustrates how the .NET Remoting infrastructure isolates an object instance within a context from object instances outside the context by using a special type of channel known as a cross-context channel and four chains of message sinks that separate inbound message processing from outbound message processing. Figure 6-1 Chains of message sinks isolate a ContextBoundObject instance from objects...

Context Attributes and Properties

You define and establish a context by attributing the context-bound type with one or more attributes that implement the IContextAttribute interface. Table 6-2 shows the methods that IContextAttribute defines. Table 6-2 Members of Table 6-2 Members of The runtime calls this method to determine whether the current context is OK for activation of the attributed type. The runtime calls this method after an attribute has indicated that the current context isn't OK for activation of the attributed...

Implementing a Custom Channel Sink

Request and response messages pass from one end of a sink chain to the other. During this traversal, sinks have the opportunity to do work based on the message information. By creating a custom sink, we can hook ourselves into the sink chain and gain access to every message before transmission and after receipt. But custom sinks aren't limited to just manipulating messages. A custom sink could perform some action based on the contents of the message. Finally, custom sinks don't have to be...

Client Formatter Sink

The first sink in the client-side channel sink chain is an instance of a client formatter sink that implements the IClientFormatterSink interface. The client formatter sink acts as a bridge between the message sink chain and the channel sink chain. As such, the client formatter sink is both a message sink and a channel sink. The IClientFormatterSink interface is a composite of the IMessageSink, IClientChannelSink, and IChannelSinkBase interfaces. The following code listing defines a class named...

Finally the message contains information identifying the calling application domain context and process as well as

lt SOAP-ENC Array id ref-18 lt item href ref-42 gt lt item href ref-43 gt lt SOAP-ENC Array gt lt a3 CrossAppDomainData id ref-42 lt _DomainID gt 1 lt _DomainID gt lt _processGuid id ref-44 gt 20c23b9b_4d09_46a8_bc29_10037f04f46f lt _processGuid gt lt a3 CrossAppDomainData gt lt a3 ChannelDataStore id ref-43 lt _channelURIs href ref-45 gt lt _extraData xsi null 1 gt lt a3 ChannelDataStore gt lt SOAP-ENC Array id ref-45 lt item id ref-4 lt SOAP-ENV Body gt lt SOAP-ENV Envelope gt

Singleton

No more than one instance of a Singleton-mode-configured type will be active at any time. An instance is activated when first accessed by a client if no other instance exists. While active, the Singleton instance will handle all subsequent client access requests by either the same client or other clients. The Singleton instance can maintain state between method calls. The following code snippet shows the programmatic method of configuring a remotable object type as a Singleton in a server...