Wednesday 20 June 2012

MS Workflow behavior extensions do not execute

MS Workflow behavior extensions do not execute

I just came across behaviour problem where I wanted to use custom behaviour, but the behaviour did not execute. I have added behaviour extension as below:

To add behaviour you need to specify your behaviour:

        <behaviorExtensions>
          <add name="dummyLogging" type="dummy.Logging, dummy"/>
        </behaviorExtensions>


Where:
name: name how its refered to.
type:- "object name" + "," +   name of the namespace"

my web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>   
  </system.web>  
  <system.serviceModel>
      <extensions>
        <behaviorExtensions>
          <add name="dummyLogging" type="dummy.Logging, dummy"/>
        </behaviorExtensions>
      </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>


Solution:


Now what I was missing was, say to MS Workflow to execute the custom behaviour. In behaviour we need to activate the behaviour, otherwise it does not get triggered.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>   
  </system.web>  
  <system.serviceModel>
      <extensions>
        <behaviorExtensions>
          <add name="dummyLogging" type="dummy.Logging, dummy"/>
        </behaviorExtensions>
      </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dummyLogging />         
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

No comments:

Post a Comment