<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Mahjayar's WebLog. : .Net Remoting</title><link>http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx</link><description>Tags: .Net Remoting</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Implications of using IPCServerChannel when connection from remote clients</title><link>http://blogs.msdn.com/mahjayar/archive/2007/09/23/implications-of-using-ipcserverchannel-when-connection-from-remote-clients.aspx</link><pubDate>Mon, 24 Sep 2007 07:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5089733</guid><dc:creator>Mahjayar</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/5089733.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=5089733</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=5089733</wfw:comment><description>&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In .Net 2.0 (Whidbey), Remoting introduced support for IPC channels. This was a quick way for local machine processes to communicate with objects hosted locally. Now there is a small behavior that&amp;nbsp; users might not be aware of when they are unmarshalling an ObjRef from an remote appdomain that has an IpcChannelServer registered. As you might know when an object that implements MarshalbyRefObject is passed across appdomains (via an argument to a function call or as a return value) Remoting sends a ObjRef instead of the actual object. This ObjRef contains information on the unique Uri that the object is identified in the remote server and the various channels via which the remote object can be reached (in addition to other information). Now imagine the scenario where the Server has registered&amp;nbsp; IpcServerChannel in addition to other channels (http and tcp) to enable local clients to communicate with the server. When a remote client gets any ObjRef from this Server it will unmarshal the ObjRef and as part of the process will create a Sink that the TransparentProxy for the ObjRef will use. The ObjRef contains a field called ChannelInfo that contains information on all server channels registered on the Server. The client iterates over the channel info list it received from the server over the list of channels registered in its local appdomain to see which client channel it can connect. &lt;/P&gt;
&lt;P&gt;This ChannelInfo field always stores the list of available channels in descending order based on their priority. The priority is of a channel denotes how "preferred" is that channel as compared to the other registered channels. If two channels have the same priority then they are sorted based on the order they were registered. In Remoting, HttpServerChannel and TcpServerChannel both have a default priority of 1 while IpcServerChannel has a priority of 20. I am going to exclude the CrossAppDomainChannel, that is registered by default and has the highest priority of 64, from this discussion as that channel is automatically not considered when an Objref is located on a remote machine. So if the server has registered the following channels TcpServerChannel, HttpServerChannel and IpcServerChannel (in that specific order), the ChannelInfo data on that ObjRef will contain the following information&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;ChannelInfo[]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;IpcChannelData&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;TcpChannelData&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;HttpChannelData&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The sink creation process for an ObjRef works in the following way.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Iterate over list of received ChannelInfo data over list of registered client channels (sorted in descending order of their prioirty just like server channels) to see if any one of the channel can connect to the Uri pointed by the RemoteChannelData object. 
&lt;LI&gt;If none of the registered channels can create a sink then Remoting will iterate over the list again to see if it can use one of the default client channels (by default Remoting will always register TcpClient, HttpClient and IpcClient if the user has not explicitly registered one).&lt;/LI&gt;&lt;/OL&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets see how the sink creation process works on the client side for couple of scenarios.&lt;/P&gt;
&lt;H2&gt;Scenario 1:&lt;/H2&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Client has explicitly registered a TcpClientChannel and HttpServerChannel. It first passes Ipc channel Uri to TcpClientChannel/HttpClientChannel and will see that both cant connect to Ipc Uri. Then it will pick the next ChannelInfo data (Tcp in this case) and pass it to TcpClientChannel. TcpClientChannel will see that it can indeed connect to the Tcp Uri and create the sink and things works fine. Once Remoting finds a Sink then it will not continue to see if other channels can also be used. It will *&lt;STRONG&gt;always&lt;/STRONG&gt;* use the first channel that recognizes the Uri.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;H2&gt;Scenario 2:&lt;/H2&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Client has explicitly registered TcpClientChannel and IpcClientChannel (order doesn't matter as Ipc will always be ahead of Tcp because of its default priority) . It first passes the Ipc channel Uri to see if any client can connect to the Uri and it will return a Ipc sink as the IpcClientChannel will successfully create the sink. Remoting will quit looking for other Sinks and use the Ipc channel sink for all future communication. When you try to make any call on the TransparentProxy you will get the following error message.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Unhandled Exception: System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: The system cannot find the file specified. &lt;/STRONG&gt;&lt;/EM&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Server stack trace:&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.Ipc.IpcPort.Connect(String portName, Boolean secure, TokenImpersonationLevel impersonationLevel, Int32 timeout)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.Ipc.ConnectionCache.GetConnection(String portName, Boolean secure, TokenImpersonationLevel level, Int32 timeout)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders&amp;amp; responseHeaders, Stream&amp;amp; responseStream)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg) &lt;/STRONG&gt;&lt;/EM&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Exception rethrown at [0]:&lt;/STRONG&gt;&lt;/EM&gt; 
&lt;P&gt;Reason being that Remoting Ipc channels cannot communicate with names pipes on remote machines. So you see that having an IpcClientChannel registered and unmarshalling an ObjRef containing an IpcServer Channel info is almost bound to fail if the ObjRef is from a remote machine.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One more associated problem with the server sending list of registered channels to the client will show up when you have a custom ServerChannel registered that is not known to the clients. In cases when a client tries to unmarshall the ObjRef from such a server it will fail to deserialize the ChannelIno as the custom ServerChannels ChannelDataStore will not be known to the client and you will get a serialization error such as&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Unhandled Exception: System.Runtime.Serialization.SerializationException: Type 'Server.MyCustomData' in Assembly 'Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. &lt;/STRONG&gt;&lt;/EM&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Server stack trace:&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ITransportHeaders&amp;amp; headers, Stream&amp;amp; stream)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage&amp;amp; responseMsg, ITransportHeaders&amp;amp; responseHeaders, Stream&amp;amp; responseStream)&lt;/STRONG&gt;&lt;/EM&gt; 
&lt;H2&gt;&amp;nbsp;&lt;/H2&gt;
&lt;H2&gt;Solutions:&lt;/H2&gt;
&lt;P&gt;There are no straight forward way for solving the above mentioned problem. Some possible solutions that I can suggest are&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;To avoid your client from picking the Ipc channel you can increase the priority of your TcpClientChannels and HttpServerChannel to something more than 20 (so they are placed above the IpcChannel). 
&lt;LI&gt;Or you can try the reverse of earlier suggestion and lower the priority of IpcClientchannel to 0. 
&lt;LI&gt;Implement &lt;STRONG&gt;ITrackingHandler&lt;/STRONG&gt; on the server and in your implementation of &lt;EM&gt;&lt;STRONG&gt;public void MarshaledObject(object obj, ObjRef or) {}&lt;/STRONG&gt;&lt;/EM&gt; you can loop over the ChannelInfo array on ObjRef and remove any ChannelInfo you dont want to send across. One draw back to this process is the fact that Remoting does not give you any way of determining the reason for marshalling the object. What I mean is there is no way of finding out if the marshalling is happening because of a call made by a remote client or a client residing on the local machine. &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5089733" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item><item><title>Custom pick a Remoting channel based on Remote object Uri</title><link>http://blogs.msdn.com/mahjayar/archive/2007/09/15/custom-pick-a-remoting-channel-based-on-remote-object-uri.aspx</link><pubDate>Sun, 16 Sep 2007 02:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4934270</guid><dc:creator>Mahjayar</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/4934270.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=4934270</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=4934270</wfw:comment><description>&lt;P&gt;One common question I see on Remoting forum is how to configure a proxy to use a particular channel from the set of registered channels for communicating when creating a proxy. For instance consider an Remoting application that exposes both a secure and non secure TcpChannel and expects clients for local box to use the unsecured channel and clients from other machine to use the secured one. Usually each channel has a priority based on which they are sorted in the app domain. When you register multiple channels with the same priority then they are added in the same order the user configured them. When a sink is to be prepared for a proxy request, Remoting will walk the registered list in descending order and find the first one that can serve the Uri scheme. So if you have multiple channels registered for the same transport medium you really don't have an option of choosing between them. &lt;/P&gt;
&lt;P&gt;I thought about this and decided to write a small wrapper channel that will help me in achieving this. The solution is to register all your usual list of channels with this channel wrapper instead of registering them with ChannelServices. Then you register this wrapper channel with ChannelServices and so each time a Sink is to be prepared Remoting will call in to our channel wrapper and it will pick the channel based on user preference. &lt;/P&gt;
&lt;P&gt;Lets take a look at this class which I call RemotingCompositeChannel.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;RemotingCompositeChannel&lt;/FONT&gt;&lt;FONT size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IChannelSender&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ITrackingHandler&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;EM&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;//Implements IChannelSender to provide IMessageSink when requested&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;//Implements ITrackingHandler so we can wire up when an CAO proxy is unmarshalled&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; RemotingCompositeChannel()&lt;/P&gt;
&lt;P&gt;: &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;UriComparisonMode&lt;/FONT&gt;&lt;FONT size=2&gt;.Exact)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; RemotingCompositeChannel(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;UriComparisonMode&lt;/FONT&gt;&lt;FONT size=2&gt; mode)&lt;/P&gt;
&lt;P&gt;{&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;EM&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;CompositeChannel can be created in two Uri comparison modes, Exact and WildcardMatch and their function is to match a Uri exactly or do pattern matches.&amp;nbsp; You first create an instance of the composite channel and register all of your regular Remoting client channels to this composite channel. Finally register the CompositeChannel with ChannelServices. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;RemotingCompositeChannel&lt;/FONT&gt;&lt;FONT size=2&gt; compositeChannel = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;RemotingCompositeChannel&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;UriComparisonMode&lt;/FONT&gt;&lt;FONT size=2&gt;.WildcardMatch);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;HttpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt; httpChannel = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;HttpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"http"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;TcpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt; tcpChannel = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;TcpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcp"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IpcClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt; ipcChannel = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IpcClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"ipc"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;TcpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt; tcpSecuredChannel = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;TcpClientChannel&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcpSecured"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;null&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;tcpSecuredChannel.IsSecured = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Wildcard pattern match mode&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;compositeChannel.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;@"http://.*"&lt;/FONT&gt;&lt;FONT size=2&gt;, httpChannel);&lt;/P&gt;
&lt;P&gt;compositeChannel.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcp://localhost:8889.*"&lt;/FONT&gt;&lt;FONT size=2&gt;, tcpChannel);&lt;/P&gt;
&lt;P&gt;compositeChannel.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcp://localhost:8891.*"&lt;/FONT&gt;&lt;FONT size=2&gt;, tcpSecuredChannel);&lt;/P&gt;
&lt;P&gt;compositeChannel.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"ipc://.*"&lt;/FONT&gt;&lt;FONT size=2&gt;, ipcChannel);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Register that single CompositeChannel&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Registered a compositechannel that contains multiple channels"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ChannelServices&lt;/FONT&gt;&lt;FONT size=2&gt;.RegisterChannel(compositeChannel, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;RemotingCompositeChannel is set between IPCChannel Priority and CrossAppdomianChannel's priority so it sits on top of all other registered cross process/machine channels. Then in your client do your regular CAO/SAO activation stuff and you should see the right channel being picked. 
&lt;P&gt;Lets see a sample MarshalByRefObject definition &lt;/P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;interface&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IRemoteService&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; SayHello(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; s);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; SayAuthenticatedHello(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; s);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MarshalByRefObject&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IRemoteService &lt;/FONT&gt;&lt;FONT size=2&gt;{ }&lt;/P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyAuthenticatedRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyRemoteService &lt;/FONT&gt;{ }&lt;/STRONG&gt;&lt;/EM&gt; &lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;virtual&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; SayAuthenticatedHello(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; s)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IPrincipal&lt;/FONT&gt;&lt;FONT size=2&gt; principal = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Thread&lt;/FONT&gt;&lt;FONT size=2&gt;.CurrentPrincipal;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Is User authenticated: "&lt;/FONT&gt;&lt;FONT size=2&gt; + principal.Identity.IsAuthenticated);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (principal.Identity.IsAuthenticated)&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Authenticated user name: "&lt;/FONT&gt;&lt;FONT size=2&gt; + principal.Identity.Name);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Authentication type: "&lt;/FONT&gt;&lt;FONT size=2&gt; + principal.Identity.AuthenticationType);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"AuthenticatedSayHello: "&lt;/FONT&gt;&lt;FONT size=2&gt; + s;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;else&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"NotAuthenticated"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;SayAuthenticatedHello will print the authenticated username of the incoming connection if any. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sample client usage&lt;/STRONG&gt;:&lt;/P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;//Register that single CompositeChannel&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Registered a compositechannel that contains multiple channels"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ChannelServices&lt;/FONT&gt;&lt;FONT size=2&gt;.RegisterChannel(compositeChannel, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Point MyRemoteService activation to port 8889 which is unsecured."&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;RemotingConfiguration&lt;/FONT&gt;&lt;FONT size=2&gt;.RegisterActivatedClientType(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt;), &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcp://localhost:8889/MyServer"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Point MyAuthenticatedRemoteService activation to port 8891 which is secured."&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;RemotingConfiguration&lt;/FONT&gt;&lt;FONT size=2&gt;.RegisterActivatedClientType(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyAuthenticatedRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt;), &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tcp://localhost:8891/MyServer"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt; server = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Type of proxy:"&lt;/FONT&gt;&lt;FONT size=2&gt; + server);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Calling anonymous method"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(server.SayHello(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Hello"&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Calling authenticated method"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(server.SayAuthenticatedHello(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Hello"&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;catch&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Exception&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Exception calling authenticated method."&lt;/FONT&gt;&lt;FONT size=2&gt; + e);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyAuthenticatedRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt; server1 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;MyAuthenticatedRemoteService&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Type of proxy:"&lt;/FONT&gt;&lt;FONT size=2&gt; + server1);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Calling anonymous method"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(server1.SayHello(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Hello"&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Calling authenticated method"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(server1.SayAuthenticatedHello(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Hello"&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;catch&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Exception&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console&lt;/FONT&gt;&lt;FONT size=2&gt;.WriteLine(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Exception calling authenticated method."&lt;/FONT&gt;&lt;FONT size=2&gt; + e);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;So ideally we want server object use the unauthenticated channel and the server1 object use the authenticated channel. 
&lt;P&gt;&lt;STRONG&gt;Output from the server:&lt;/STRONG&gt; 
&lt;P&gt;Server started. Press any key to terminate&lt;BR&gt;AnonymousSayHello : Hello&lt;BR&gt;Is User authenticated: False&lt;BR&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;AnonymousSayHello : Hello&lt;BR&gt;Is User authenticated: True&lt;BR&gt;Authenticated user name: [MyDomainRemovedForSecuritySake]\mahjayar ==&amp;gt;Success. Used the authenticated channel&lt;BR&gt;Authentication type: NTLM&lt;/FONT&gt;&lt;/STRONG&gt; 
&lt;P&gt;&lt;STRONG&gt;Output From Client:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Registered a compositechannel that contains multiple channels&lt;BR&gt;Point MyRemoteService activation to port 8889 which is unsecured.&lt;BR&gt;Point MyAuthenticatedRemoteService activation to port 8891 which is secured.&lt;BR&gt;Unmarshalled object Server.MyRemoteService&lt;BR&gt;IS transparent Proxy&lt;BR&gt;&lt;FONT color=#000080&gt;Type of proxy:Server.MyRemoteService&lt;BR&gt;Calling anonymous method&lt;BR&gt;Hello&lt;BR&gt;Calling authenticated method&lt;BR&gt;NotAuthenticated&lt;BR&gt;&lt;STRONG&gt;Unmarshalled object Server.MyAuthenticatedRemoteService&lt;BR&gt;IS transparent Proxy&lt;BR&gt;Type of proxy:Server.MyAuthenticatedRemoteService&lt;BR&gt;Calling anonymous method&lt;BR&gt;Hello&lt;BR&gt;Calling authenticated method&lt;BR&gt;AuthenticatedSayHello: Hello&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;As you can see the first client's call to AuthenticatedSayHello comes back as unauthorized and the second client (of type MyAuthenticatedRemoteService) uses the authorized channel.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;PS: The usual disclaimer applies the RemotingCompositeChannel.cs class attached to the post. Its my own code and not tested by Microsoft or clarifiers for support from Microsoft. Use them in your code as you wish and if you find any bugs or have any suggestions for improvement then please post back. The code has enough comments to explain the reasoning for each method. This should work for both CAO and SAO objects. I will leave the SAO object verification up to the user.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;: Added a link to the file from my Skydrive account. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://cid-1020651b1389d347.skydrive.live.com/self.aspx/Public/RemotingCompositeChannel.cs" mce_href="http://cid-1020651b1389d347.skydrive.live.com/self.aspx/Public/RemotingCompositeChannel.cs"&gt;http://cid-1020651b1389d347.skydrive.live.com/self.aspx/Public/RemotingCompositeChannel.cs&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4934270" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/mahjayar/attachment/4934270.ashx" length="7183" type="text/plain" /><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item><item><title>Visual Studio 2005 SP1 Released</title><link>http://blogs.msdn.com/mahjayar/archive/2006/12/17/visual-studio-whidbey-sp1-released.aspx</link><pubDate>Sun, 17 Dec 2006 22:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1312551</guid><dc:creator>Mahjayar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/1312551.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=1312551</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=1312551</wfw:comment><description>&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;: Turns out this SP was only for the&amp;nbsp;Visual Studio tools part and&amp;nbsp;not for the framework. Which means the QFE wont be in this. Sorry about that (Will confirm before posting the next time).&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;Over the weekend, Visual Studio team released SP1 for &lt;/STRIKE&gt;&lt;A class="" href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx" mce_href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx"&gt;&lt;STRIKE&gt;Whidbey&lt;/STRIKE&gt;&lt;/A&gt;&lt;STRIKE&gt;. Usually when we release a SP, it will contain fixes for all the QFE's released till that point. This means that the fix for the Remoting bug that I talked &lt;/STRIKE&gt;&lt;A class="" href="http://blogs.msdn.com/dotnetremoting/archive/2006/10/14/whidbey-remoting-accessviolation-problem-maheshwar-jayaraman.aspx" mce_href="http://blogs.msdn.com/dotnetremoting/archive/2006/10/14/whidbey-remoting-accessviolation-problem-maheshwar-jayaraman.aspx"&gt;&lt;STRIKE&gt;about&lt;/STRIKE&gt;&lt;/A&gt;&lt;STRIKE&gt; &lt;/STRIKE&gt;&lt;A class="" href="http://blogs.msdn.com/mahjayar/archive/2006/10/14/debugging-whidbey-remoting-accessviolation-problem.aspx" mce_href="http://blogs.msdn.com/mahjayar/archive/2006/10/14/debugging-whidbey-remoting-accessviolation-problem.aspx"&gt;&lt;STRIKE&gt;here&lt;/STRIKE&gt;&lt;/A&gt;&lt;STRIKE&gt; should be available in the SP. Give the SP a try&lt;/STRIKE&gt;.&lt;/P&gt;
&lt;P&gt;Maheshwar Jayaraman&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1312551" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item><item><title>Debugging Whidbey Remoting AccessViolation Problem</title><link>http://blogs.msdn.com/mahjayar/archive/2006/10/14/debugging-whidbey-remoting-accessviolation-problem.aspx</link><pubDate>Sat, 14 Oct 2006 21:12:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:826025</guid><dc:creator>Mahjayar</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/826025.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=826025</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=826025</wfw:comment><description>&lt;p&gt;There has been&amp;nbsp;&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=370352&amp;amp;SiteID=1"&gt;some&lt;/a&gt; &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=178126&amp;amp;SiteID=1"&gt;cases&lt;/a&gt; &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=423240&amp;amp;SiteID=1"&gt;where&lt;/a&gt; users have reported an AccessViolation when upgrading their Remoting app's to Whidbey. Some users found that the problem reprod only when they had some anti virus software (Nod32 in particular) installed and the AV went away when they configured the anti-virus not to scan the problematic exe's. In addition to working on WCF, I am also the dev servicing Remoting for all versions of the framework. We had never seen this problem in our internal testing and since there were enough cases out there to indicate that its not due to one single machine/configuration, we decided to see if there really was a problem.&lt;/p&gt; &lt;h3&gt;Reproing the problem.&lt;/h3&gt; &lt;p&gt;First we had to repro the problem and since most users said it was reproducible reliably with Nod32 anti virus installed, we installed a trial version of the software and wrote a simple remoting app that just echoes the value sent by the client. The client was able to connect to the server and have its input echoed but when the client shutdown, it caused the server process to AV. &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indi&lt;br&gt;cation that other memory is corrupt.&lt;br&gt;at System.Net.UnsafeNclNativeMethods.OSSOCK.WSAGetOverlappedResult(SafeCloseSocket socketHandle, IntPtr overlapped, U&lt;br&gt;Int32&amp;amp; bytesTransferred, Boolean wait, IntPtr ignored)&lt;br&gt;at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverl&lt;br&gt;apped* nativeOverlapped)&lt;br&gt;at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverla&lt;br&gt;pped* pOVERLAP)&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp;  &lt;h3&gt;Debugging the problem:&lt;/h3&gt; &lt;p&gt;Now that the issue was reproducible, we ran the server process in windbg and ran the repro again. With windbg attached the AV is caught as a first chance exception.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;First chance exceptions are reported before any exception handling.&lt;br&gt;This exception may be expected and handled.&lt;br&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;eax=00000000&lt;/font&gt;&lt;/strong&gt; ebx=001872f0 ecx=011efa74 edx=00000000 esi=012a2498 edi=011efc48&lt;br&gt;eip=20b0cd29 esp=011ef9cc ebp=011efa00 iopl=0 nv up ei ng nz na pe nc&lt;br&gt;cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010286&lt;br&gt;imon!NOD32Ioctl+0xaec9:&lt;br&gt;20b0cd29 8910 mov dword ptr [eax],edx ds:0023:00000000=????????&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So Nod32 tried to save value of EBX register in EAX which means that the system expects the register to hold a pointer reference and not value 0. Just to be sure that the heap isnt corrupted, ran the !verifyheap command.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;0:005&amp;gt; !verifyheap&lt;br&gt;-verify will only produce output if there are errors in the heap&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;VerifyHeap command reports a clean heap. Lets take a look at the stacktrace and unwind the stack.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;0:005&amp;gt; !clrstack&lt;br&gt;OS Thread Id: 0x89c (5)&lt;br&gt;ESP EIP &lt;br&gt;011efa50 20b0cd29 [NDirectMethodFrameStandaloneCleanup: 011efa50] System.Net.UnsafeNclNativeMethods+OSSOCK.WSAGetOverlappedResult(System.Net.SafeCloseSocket, IntPtr, UInt32 ByRef, Boolean, IntPtr)&lt;br&gt;011efa6c 7a60e1ce System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)&lt;br&gt;011efaa4 793d6ac4 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)&lt;br&gt;011efc48 79e88f63 [GCFrame: 011efc48] &lt;/font&gt; &lt;p&gt;&lt;font color="#000080"&gt;0:005&amp;gt; kb 100&lt;br&gt;ChildEBP RetAddr Args to Child &lt;br&gt;WARNING: Stack unwind information not available. Following frames may be wrong.&lt;br&gt;011efa00 00fc0a97 000005b4 012a2498 011efa74 imon!NOD32Ioctl+0xaec9&lt;br&gt;011efa38 7a60e1ce 012a2084 00000040 012a2498 CLRStub[StubLinkStub]@fc0a97&lt;br&gt;011efa98 793d6ac4 00000000 00000000 00000000 System_ni!System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+0xb2 [f:\RTM\ndp\fx\src\Net\System\Net\Sockets\_BaseOverlappedAsyncResult.cs @ 360]&lt;br&gt;011efab8 79e88f63 00000000 00000000 00000000 mscorlib_ni!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+0x68 [f:\RTM\ndp\clr\src\BCL\System\Threading\Overlapped.cs @ 85]&lt;br&gt;011efacc 79e88ee4 011efc80 00000001 011efc74 mscorwks!CallDescrWorker+0x33 [f:\rtm\ndp\clr\src\vm\i386\asmhelpers.asm @ 936]&lt;br&gt;011efb4c 79f20212 011efc80 00000001 011efc74 mscorwks!CallDescrWorkerWithHandler+0xa3 [f:\rtm\ndp\clr\src\vm\class.cpp @ 13568]&lt;br&gt;011efb6c 79f201bc 011efc7c 00000001 011efc74 mscorwks!DispatchCallBody+0x1e [f:\rtm\ndp\clr\src\vm\crossdomaincalls.cpp @ 504]&lt;br&gt;011efbd0 79f2024b 011efc7c 00000001 011efc74 mscorwks!DispatchCallDebuggerWrapper+0x3d [f:\rtm\ndp\clr\src\vm\crossdomaincalls.cpp @ 528]&lt;br&gt;011efc04 7a07bebf 011efc7c 00000001 011efc74 mscorwks!DispatchCallNoEH+0x51 [f:\rtm\ndp\clr\src\vm\crossdomaincalls.cpp @ 620]&lt;br&gt;011efcac 79ecb4a4 012a246c 001872f0 00000001 mscorwks!BindIoCompletionCallBack_Worker+0x123 [f:\rtm\ndp\clr\src\vm\comthreadpool.cpp @ 702]&lt;br&gt;011efcbc 79ecb442 011efd98 011efd44 79f93fe6 mscorwks!ManagedThreadBase_DispatchInner+0x4d [f:\rtm\ndp\clr\src\vm\threads.cpp @ 16923]&lt;br&gt;011efd50 79ecb364 011efd98 bdde0c59 001872f0 mscorwks!ManagedThreadBase_DispatchMiddle+0xb0 [f:\rtm\ndp\clr\src\vm\threads.cpp @ 16974]&lt;br&gt;011efd8c 7a0e1b7e 011efd98 00000001 00000000 mscorwks!ManagedThreadBase_DispatchOuter+0x6d [f:\rtm\ndp\clr\src\vm\threads.cpp @ 17085]&lt;br&gt;011efdb4 7a0e1bab 00000001 7a07bdfe 011efdec mscorwks!ManagedThreadBase_FullTransitionWithAD+0x25 [f:\rtm\ndp\clr\src\vm\threads.cpp @ 17107]&lt;br&gt;011efdc8 7a07c031 00000001 7a07bdfe 011efdec mscorwks!ManagedThreadBase::ThreadPool+0x13 [f:\rtm\ndp\clr\src\vm\threads.cpp @ 17149]&lt;br&gt;011efe1c 7a07c063 00000040 00000000 012a2498 mscorwks!BindIoCompletionCallbackStubEx+0x8c [f:\rtm\ndp\clr\src\vm\comthreadpool.cpp @ 777]&lt;br&gt;011efe30 79f2f3b0 00000040 00000000 012a2498 mscorwks!BindIoCompletionCallbackStub+0x13 [f:\rtm\ndp\clr\src\vm\comthreadpool.cpp @ 797]&lt;br&gt;011efe94 79ecb00b 00000000 badb0d00 00000000 mscorwks!ThreadpoolMgr::CompletionPortThreadStart+0x406 [f:\rtm\ndp\clr\src\vm\win32threadpool.cpp @ 4060]&lt;br&gt;011effb4 7c80b683 00183ff0 7c919a9c 7c800000 mscorwks!Thread::intermediateThreadProc+0x49 [f:\rtm\ndp\clr\src\vm\threads.cpp @ 3001]&lt;br&gt;011effec 00000000 79ecafc5 00183ff0 00000000 KERNEL32!BaseThreadStart+0x37 [d:\nt\base\win32\client\support.c @ 532]&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Looks like Network Class Libraries (NCL) called in to unmanaged code WSAGetOverlappedResult and the call to that AV'd. Since the unmanaged call goes straight to Nod32 it means that its an LSP which sits on top of TCP. To confirm it, ran a query to see the list of installed LSP's on the system.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;C:\Program Files\Microsoft Platform SDK\Samples\NetDS\WinSock\LSP&amp;gt;nonifslsp\XP32_RETAIL\instlsp.exe -p &lt;/font&gt; &lt;p&gt;&lt;font color="#000080"&gt;Winsock 32-bit Catalog:&lt;br&gt;=======================&lt;br&gt;1019 - NOD32 protected [MSAFD Tcpip [TCP/IP]]&lt;br&gt;1020 - NOD32 protected [MSAFD Tcpip [UDP/IP]]&lt;br&gt;1021 - NOD32 protected [MSAFD Tcpip [RAW/IP]]&lt;br&gt;1022 - NOD32 protected [RSVP UDP Service Provider]&lt;br&gt;1023 - NOD32 protected [RSVP TCP Service Provider]&lt;br&gt;1001 - MSAFD Tcpip [TCP/IP]&lt;br&gt;1002 - MSAFD Tcpip [UDP/IP]&lt;br&gt;1003 - MSAFD Tcpip [RAW/IP]&lt;br&gt;1004 - RSVP UDP Service Provider&lt;br&gt;1005 - RSVP TCP Service Provider&lt;br&gt;1006 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{EF980A36-42D5-4F46-8C5E-B9D289A5A7AE}] SEQPACKET 0&lt;br&gt;1007 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{EF980A36-42D5-4F46-8C5E-B9D289A5A7AE}] DATAGRAM 0&lt;br&gt;1008 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{14C32293-28C3-40B2-A4FF-FD3B9147252F}] SEQPACKET 1&lt;br&gt;1009 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{14C32293-28C3-40B2-A4FF-FD3B9147252F}] DATAGRAM 1&lt;br&gt;1010 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{D7376ECB-770A-4B34-8AFB-E553ADEA4B9A}] SEQPACKET 2&lt;br&gt;1011 - MSAFD NetBIOS [\Device\NetBT_Tcpip_{D7376ECB-770A-4B34-8AFB-E553ADEA4B9A}] DATAGRAM 2&lt;br&gt;1018 - NOD32&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So Nod32 does indeed sit on top of Microsoft's Tcp provider and is routing calls. When the client disconnects then the server receives that socket shutdown and as part of that NCL tries to get the overlapped result on that socket. If you look at the disassembly at the place the AV happened you will find that its all in Nod32 code which is proprietary.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;0:005&amp;gt; u 20b0cd29-10 20b0cd29+10&lt;br&gt;imon!NOD32Ioctl+0xaeb9:&lt;br&gt;20b0cd19 4c dec esp&lt;br&gt;20b0cd1a 241c and al,1Ch&lt;br&gt;20b0cd1c 8b4604 mov eax,dword ptr [esi+4]&lt;br&gt;20b0cd1f 5f pop edi&lt;br&gt;20b0cd20 8901 mov dword ptr [ecx],eax&lt;br&gt;20b0cd22 8b442420 mov eax,dword ptr [esp+20h]&lt;br&gt;20b0cd26 8b560c mov edx,dword ptr [esi+0Ch]&lt;br&gt;&lt;font color="#ff0000"&gt;20b0cd29 8910 mov dword ptr [eax],edx ==&amp;gt; line where exception was thrown.&lt;/font&gt;&lt;br&gt;20b0cd2b 8b542424 mov edx,dword ptr [esp+24h]&lt;br&gt;20b0cd2f 8b4e08 mov ecx,dword ptr [esi+8]&lt;br&gt;20b0cd32 33c0 xor eax,eax&lt;br&gt;20b0cd34 890a mov dword ptr [edx],ecx&lt;br&gt;20b0cd36 8b4e08 mov ecx,dword ptr [esi+8]&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So disassembling that code will not be possible and so lets take a step back and try to debug the next code in the stack before Nod32. Lets take a look at the arguments passed in to the WSAGetOverlappedResult call. The signature is defined in NCL as follows.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;[DllImport(WS2_32, SetLastError=true)]&lt;br&gt;internal static extern bool WSAGetOverlappedResult(&lt;br&gt;[In] SafeCloseSocket socketHandle,&lt;br&gt;[In] IntPtr overlapped,&lt;br&gt;[Out] out uint bytesTransferred,&lt;br&gt;[In] bool wait,&lt;br&gt;[In] IntPtr ignored&lt;br&gt;);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Lets take a look at the invocation of this function in BaseOverlappedAsyncResult.CompletionPortCallback().  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;bool success = UnsafeNclNativeMethods.OSSOCK.WSAGetOverlappedResult(&lt;br&gt;socket.SafeHandle,&lt;br&gt;(IntPtr)nativeOverlapped,&lt;br&gt;out numBytes,&lt;br&gt;false,&lt;br&gt;IntPtr.Zero);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;From the list of arguments lets try to rule out potentially problematic arguments. Socket.SafeHandle isnt null or&amp;nbsp;NCL would have NullRef'd in managed code itself. In the debugger it was ensured that the nativeOverlapped structure wasn't null. numBytes is passed by reference&amp;nbsp;and the&amp;nbsp;the value is&amp;nbsp;passed in to this function by&amp;nbsp;&amp;nbsp;_IOCompletionCallback.PerformIOCompletionCallback. The bool is passed by value&amp;nbsp;and so that leaves the the only other variable&amp;nbsp;IntPtr.Zero that could be&amp;nbsp;the problematic argument.&amp;nbsp;But this part of code&amp;nbsp;hasn't been changed from V1 which means that if this&amp;nbsp;is the issue then it should repro in V1 and V1.1 as well.&amp;nbsp;Since its a Whidbey only issue may be&amp;nbsp;something changed in IntPtr implementation from V1.1 and 2.0. Lets take a look at the struct IntPtr.Zero implementation in Whidbey.  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;unsafe private void* m_value; &lt;/font&gt; &lt;p&gt;&lt;font color="#000080"&gt;public static readonly IntPtr Zero; &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So we have memory allocated for the struct but there is no memory allocated for the the void pointer!&amp;nbsp;This means that if someone tries to reference/dereference the value pointed by this IntPtr struct it will either throw NullRef in managed code or throw AV in unmanaged code. So this explains the AV in this case. So does this mean that the implementation has changed in V2.0 only? Lets take a look at the implementation of IntPtr.Zero in V1.1  &lt;blockquote&gt; &lt;p&gt;&lt;font color="#000080"&gt;public static readonly IntPtr Zero = new IntPtr(0);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Sure enough the implementation has changed. In v1.1 the struct was initialized with a pointer pointing to zero and hence when Nod32 tried to dereference the pointer it works fine. So next question is should Nod32 be dereferencing this pointer? For that lets see what MSDN documents about the &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsagetoverlappedresult_2.asp"&gt;WSAGetOverlappedResult&lt;/a&gt;&amp;nbsp; method.  &lt;p&gt;&amp;nbsp;  &lt;blockquote&gt;&lt;pre&gt;&lt;font color="#000080"&gt;&lt;b&gt;BOOL WSAAPI&lt;/b&gt; &lt;b&gt;WSAGetOverlappedResult(&lt;/b&gt;
  &lt;b&gt;SOCKET&lt;/b&gt; &lt;i&gt;&lt;a href="http://msdn.microsoft.com/"&gt;s&lt;/a&gt;&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000080"&gt;&lt;b&gt;,
&lt;/b&gt;  &lt;b&gt;LPWSAOVERLAPPED&lt;/b&gt; &lt;i&gt;&lt;a href="http://msdn.microsoft.com/"&gt;lpOverlapped&lt;/a&gt;&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000080"&gt;&lt;b&gt;,
&lt;/b&gt;  &lt;b&gt;LPDWORD&lt;/b&gt; &lt;i&gt;&lt;a href="http://msdn.microsoft.com/"&gt;lpcbTransfer&lt;/a&gt;&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000080"&gt;&lt;b&gt;,
&lt;/b&gt;  &lt;b&gt;BOOL&lt;/b&gt; &lt;i&gt;&lt;a href="http://msdn.microsoft.com/"&gt;fWait&lt;/a&gt;&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;font color="#000080"&gt;&lt;b&gt;,
&lt;/b&gt;  &lt;b&gt;LPDWORD&lt;/b&gt; &lt;i&gt;&lt;a href="http://msdn.microsoft.com/"&gt;lpdwFlags&lt;/a&gt;&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;b&gt;
&lt;/b&gt;&lt;font color="#000080"&gt;&lt;b&gt;);&lt;/b&gt;
&lt;/font&gt;&lt;/pre&gt;
&lt;h6&gt;&lt;font color="#000080"&gt;Parameters&lt;/font&gt;&lt;/h6&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;i&gt;&lt;font color="#000080"&gt;s&lt;/font&gt;&lt;/i&gt; 
&lt;dd&gt;&lt;font color="#000080"&gt;[in] A descriptor identifying the socket. This is the same socket that was specified when the overlapped operation was started by a call to &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsarecv_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSARecv&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;, &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsarecvfrom_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSARecvFrom&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;, &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsasend_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSASend&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;, &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsasendto_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSASendTo&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;, or &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsaioctl_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSAIoctl&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;. &lt;/font&gt;
&lt;dt&gt;&lt;i&gt;&lt;font color="#000080"&gt;lpOverlapped&lt;/font&gt;&lt;/i&gt; 
&lt;dd&gt;&lt;font color="#000080"&gt;[in] A pointer to a &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsaoverlapped_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSAOVERLAPPED&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt; structure that was specified when the overlapped operation was started. This parameter must not be a NULL pointer. &lt;/font&gt;
&lt;dt&gt;&lt;i&gt;&lt;font color="#000080"&gt;lpcbTransfer&lt;/font&gt;&lt;/i&gt; 
&lt;dd&gt;&lt;font color="#000080"&gt;[out] A pointer to a 32-bit variable that receives the number of bytes that were actually transferred by a send or receive operation, or by &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsaioctl_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSAIoctl&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;. This parameter must not be a NULL pointer. &lt;/font&gt;
&lt;dt&gt;&lt;i&gt;&lt;font color="#000080"&gt;fWait&lt;/font&gt;&lt;/i&gt; 
&lt;dd&gt;&lt;font color="#000080"&gt;[in] A flag that specifies whether the function should wait for the pending overlapped operation to complete. If TRUE, the function does not return until the operation has been completed. If FALSE and the operation is still pending, the function returns FALSE and the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsagetlasterror_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSAGetLastError&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt; function returns WSA_IO_INCOMPLETE. The &lt;i&gt;fWait&lt;/i&gt; parameter may be set to TRUE only if the overlapped operation selected the event-based completion notification. &lt;/font&gt;
&lt;dt&gt;&lt;i&gt;&lt;font color="#000080"&gt;lpdwFlags&lt;/font&gt;&lt;/i&gt; 
&lt;dd&gt;&lt;font color="#000080"&gt;[out] A pointer to a 32-bit variable that will receive one or more flags that supplement the completion status. If the overlapped operation was initiated through &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsarecv_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSARecv&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt; or &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/wsarecvfrom_2.asp"&gt;&lt;b&gt;&lt;font color="#000080"&gt;WSARecvFrom&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;font color="#000080"&gt;, this parameter will contain the results value for &lt;i&gt;lpFlags&lt;/i&gt; parameter. &lt;font color="#ff0000"&gt;This parameter must not be a NULL pointer&lt;/font&gt;. &lt;/font&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/blockquote&gt;
&lt;p&gt;Turns out the flag cannot be a null pointer which means that NCL was passing the wrong argument for this. So the fix is to pass a valid pointer to the unmanaged API.&lt;/p&gt;
&lt;p&gt;Now for users that want to try this out without having to install Nod32 (because you already have anti-virus installed) then you can use the LSP route. &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&amp;amp;displaylang=en"&gt;Windows SDK&lt;/a&gt; ships a LSP sample that you can install on your box on top of TCP and then run any Remoting app and sure enough you can find odd behaviors. I will leave that as an exercise for readers.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to get the QFE:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We have issued an QFE for this and since it hasnt been through the requirements for a public KB yet this is only available by calling Microsoft product support. Dont worry this should be a free call. To get this QFE call Microsoft Product Support Services (&lt;a href="https://mail.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fsupport.microsoft.com%2f"&gt;http://support.microsoft.com&lt;/a&gt;) and ask for the Hotfix for KB number 923028 or mention that you need the fix for "Visual Studio Update QFE 4333" (Thats the internal bug # of this).
&lt;p&gt;&amp;nbsp;
&lt;p&gt;Maheshwar Jayaraman [WCF]
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=826025" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item><item><title>Configuring Kerberos delegation in Remoting</title><link>http://blogs.msdn.com/mahjayar/archive/2006/07/11/662618.aspx</link><pubDate>Tue, 11 Jul 2006 23:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:662618</guid><dc:creator>Mahjayar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/662618.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=662618</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=662618</wfw:comment><description>&lt;P&gt;One of the common question we have in remoting forums is how to configure Kerberos delegation with .Net 2.0. Rick Rainey has an excellent detailed post on how to configure this over at the &lt;A href="http://blogs.msdn.com/dotnetremoting/archive/2006/07/06/662599.aspx"&gt;remoting blog&lt;/A&gt;. Check it out!. Thanks Rick.&lt;/P&gt;
&lt;P&gt;Maheshwar Jayaraman&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=662618" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item><item><title>Announcing the .Net Remoting team blog</title><link>http://blogs.msdn.com/mahjayar/archive/2006/04/07/571082.aspx</link><pubDate>Fri, 07 Apr 2006 23:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:571082</guid><dc:creator>Mahjayar</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mahjayar/comments/571082.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mahjayar/commentrss.aspx?PostID=571082</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mahjayar/rsscomments.aspx?PostID=571082</wfw:comment><description>&lt;P&gt;I am also part of the team that supports all versions of .Net Remoting. We found that lot of customers had simialr questions/concerns in migrating from .Net 1.1 to .Net 2.0 and we thought it would be great if we started a team blog for Remoting. We have our first post that talks about how to setup eventing in remoting. This has been a common question from customers and we thought this will be a good starting post. Blog is set up at &lt;A href="/dotnetremoting"&gt;http://blogs.msdn.com/dotnetremoting&lt;/A&gt; and the first post can be found &lt;A href="/dotnetremoting/archive/2006/04/07/571020.aspx"&gt;here&lt;/A&gt;. Email capability is enabled and it comes directly to our team. We have a pretty quick turnaround time for answering (most cases same day) so fire those questions our way. If you have&amp;nbsp;any ideas on what you want to see blogged about remoting then let us know.&lt;/P&gt;
&lt;P&gt;Mahesh&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=571082" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mahjayar/archive/tags/.Net+Remoting/default.aspx">.Net Remoting</category></item></channel></rss>