2010-05-21 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 21 May 2010 07:13:17 +0000 (07:13 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 21 May 2010 07:13:17 +0000 (07:13 -0000)
* ServiceHostBase.cs : ServiceMetadataBehavior and ServiceDebugBehavior
  are special. They must be applied in prior to other behaviors so that
  newly populated ChannelDispatchers are applied behaviors accordingly.

svn path=/trunk/mcs/; revision=157666

mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs

index 547c84630ac913a892f9be7b6ee6ea54881e8504..cb2b3e79b2cb860938440012e533dde82db97b36 100755 (executable)
@@ -1,3 +1,9 @@
+2010-05-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : ServiceMetadataBehavior and ServiceDebugBehavior
+         are special. They must be applied in prior to other behaviors so that
+         newly populated ChannelDispatchers are applied behaviors accordingly.
+
 2010-05-21  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ServiceHostBase.cs : remove Sleep() hack and wait channels to get
index 45c51f907102d2890497fcaa9ad3456c85bcdb07..ded567df07a47e07e39d0ebdf15641cd99350b48 100644 (file)
@@ -395,8 +395,19 @@ namespace System.ServiceModel
 
                        //After the ChannelDispatchers are created, and attached to the service host
                        //Apply dispatching behaviors.
+                       //
+                       // This behavior application order is tricky: first only
+                       // ServiceDebugBehavior and ServiceMetadataBehavior are
+                       // applied, and then other service behaviors are applied.
+                       // It is because those two behaviors adds ChannelDispatchers
+                       // and any other service behaviors must be applied to
+                       // those newly populated dispatchers.
                        foreach (IServiceBehavior b in Description.Behaviors)
-                               b.ApplyDispatchBehavior (Description, this);
+                               if (b is ServiceMetadataBehavior || b is ServiceDebugBehavior)
+                                       b.ApplyDispatchBehavior (Description, this);
+                       foreach (IServiceBehavior b in Description.Behaviors)
+                               if (!(b is ServiceMetadataBehavior || b is ServiceDebugBehavior))
+                                       b.ApplyDispatchBehavior (Description, this);
 
                        builder.ApplyDispatchBehaviors ();
                }