[Mono-dev] WCF: InstanceContextMode.PerSession
fourmont at gmx.de
Sun Jan 9 09:15:04 EST 2011
> One (slightly) better approach is to avoid configuration. It is
> extraneous stack to the actual code implementation for us and often
> left not-implemented.
After changing to configuration in code and tinkering some more I came
to the next hurdle: session instance handling.
Currently Mono creates a new instance of the service object for every
method call. That's not what's usually desired for sessions.
If you use the default instancing behavior in WCF, all calls between a
WCF client object are handled by the same service instance. Therefore,
at the application level, you can think of a session as enabling
application behavior similar to local call behavior. For example, when
you create a local object:
- A constructor is called.
- All subsequent calls made to the WCF client object reference are
processed by the same object instance.
- A destructor is called when the object reference is destroyed.
As usual the details are even more complex as WCF is highly
customizable. A helpful read is
But it comes down to this: if you set
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
on a service, all client calls in one session should go to the same
service instance and the service instance should be disposed when the
I created a Nunit Test (passes on .net fails on mono 2.8.1) for this and
filed bug https://bugzilla.novell.com/show_bug.cgi?id=663278
If there's anything I can do to help, just let me know.
More information about the Mono-devel-list