Share via


WCF June/July CTP: QnA

We have an internal alias where people developing apps on WCF post questions. Generally we see some questions that are commonly faced by people and thought it would be a good idea to make a quick HowTo or QnA on some topics that WCF newbie users may find useful.

Q: How to know if a server channel is sessionful or not?

A: Couple of ways.

       OperationContext.Current.SessionId != null

or    OperationContext.Current.Channel.SessionId != null

Q: WCF service runtime disposes off all input/output parameters once the operation is invoked. How can I cache the input arguments?

A: Mark you operation implementation with OperationBehavior with AutoDisposeParameters set to false.

   [OperationBehavior(AutoDisposeParameters=false)]

   public void Foo(Message m, FooDisposableObj f)

   {

      //Implementation

   }

Q: Why is OperationContext.Current.RequestContext null?

A: Because the operation is OneWay. RequestContext is not null only for request/reply.

 

Q: Why does the first call on a newly created channel take longer to complete than subsequent calls?

A: Its possible that the delay is due to AutoOpen feature. If a channel is not in Opened state when a call is made then the channel is "auto opened" for the user. Users can explicitly open a channel by doing

((IClientChannel)channel).Open();

or proxy.Open() ==> If proxy is of type ClientBase

 

Q: If a binding does not use ReliableMessaging, then is the order preserved for all async calls made on a Channel using that binding?

A: Yes.

Q: What's the difference between ConcurrencyMode.Single and ConcurrencyMode.Reentrant. They seem to process only one message at any time?

A: Reentrant is actually analogus to ConcurrencyMode.Single in that it will process only one message at a given time. The only difference is that the service is unblocked to process a new message when the user makes an outgoing call while processing a message.

Q: If I have multiple messages/channels waiting for a throttle (Call/Session/InstanceContext), how fair is WCF to the waiters?

A: First come first serve.

Q: Whats the implications of using IsOneWay=true on an OperationContract?

A: KennyW has a wonderful post on this at https://kennyw.com/indigo/130

Q: How do I know if the throttle limit set on the ServiceHost is too restrictive?

A: Well thats a decision the customer needs to make based on the load they expect. But in test environment, enable logging and if there is too many occurances of

"The system hit the limit set for the '[One of the throttles]' throttle. Throttle value can be changed by modifying... " then it probably means that that particular throttle is too restrictive.

Thats all the time I have today for this list. There is lot more that I will try to post by the end of the week.

Maheshwar Jayaraman [WCF]