共用方式為


WCF Instancing mode default is InstanceContextMode.PerSession

Keith Brown has been experimenting with InstanceContextMode.  This is the property on System.ServiceModel.ServiceBehaviorAttribute that determines how WCF handles instancing.  Keith correctly notes that the current documentation is wrong about the default value for this property.  The default value is not PerCall, but rather PerSession.  We changed this in the June CTP.  Here's the reasoning:

"With PerCall, users who required a session in their ServiceContract would get a session that lasted the duration of a single call unless they changed the InstanceContextMode to PerSession.

With the new default of PerSession, users who require a session will get instance lifetime tied to session channel lifetime, as they expect. Users who don't require a session in their contract will still get instance lifetime that looks like PerCall. The benefit of this change is that users get the instance lifetime they expect once they set session requirements on the contract, without having to tweak the InstanceContextMode."

The docs have been updated on wcf.netfx3.com under the resources tab.

If you are building your service to be stateless, it shouldn't matter if the same instance is reused for the lifetime of a channel.  Explicitly setting InstanceContextMode to PerCall simply means we will create a new InstanceContext for each call instead of reusing the instance associated with the session.