1

I am looking into a problem whereby it seems that there is some cross contamination between different operations when retrieving an extension instance from OperationContext. It is one of those annoying concurrency based hard to replicate issues. I strongly suspect some sort of threading issue. We are running WCF services on IIS7.0/.NET 4 integrated mode. The relevant section of our extension is as follows:

public class CustomContext : IExtension<OperationContext>, ICustomContext
{
    public CustomContext Current
    {
        get
        {
            return OperationContext.Current != null ? OperationContext.Current.Extensions.Find<CustomContext>() : null;
        }
    }

   ...

 }

The above is called from a PostSharp aspect, I'm not sure if this is relevant of not? Given the above are there any obvious conditions under which the call to current might return the wrong CustomContext instance? Apologies for such an open ended question.

Myles McDonnell
  • 12,943
  • 17
  • 66
  • 116
  • 1
    You should add what [InstanceContextMode](http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode(v=vs.100).aspx) and [ConcurrancyMode](http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode(v=vs.100).aspx) your service is set to. This kinda old but [still pretty good MSDN article](http://msdn.microsoft.com/en-us/magazine/cc163590.aspx) explains the various options and use cases for `InstanceContextMode`. – Sixto Saez Oct 08 '12 at 15:27
  • Great, just the sort input I'm looking for, Thanks Sixto :) – Myles McDonnell Oct 08 '12 at 20:43

0 Answers0