title: VS2010 "Update Service Reference" to WCF where behavior extensions inspect and change messages
body: <p>I'm using an encrypted timestamp to secure communications between a WCF service in my web server and another in the 'mid-tier'. In the calling service (the client in this exchange) I'm using a DLL whose class inherits System.ServiceModel.Configuration.BehaviorExtensionElement to provide functionality implementing System.ServiceModel.Description.IEndpointBehavior and System.ServiceModel.Dispatcher.IClientMessageInspector. This is glued in via the web.config file with the sections </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;extensions&gt;
   &lt;behaviorExtensions&gt;
    &lt;add name="MessageInspectorBehavior" type="MessageInspectorDLL.MessageInspectorBehaviorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
   &lt;/behaviorExtensions&gt;
  &lt;/extensions&gt;
  
  &lt;endpointBehaviors&gt;
    &lt;behavior name="MessageInspectorEndpointBehavior"&gt;
      &lt;MessageInspectorBehavior /&gt;
    &lt;/behavior&gt;
  &lt;/endpointBehaviors&gt;
  </code></pre>
  
  <p>and then these are hooked up to the mid-tier WCF with entries like this one</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;client&gt;
    &lt;endpoint address="http://blah.cloudapp.net:8080/BlahService.svc"
      behaviorConfiguration="MessageInspectorEndpointBehavior" binding="customBinding"
      bindingConfiguration="CustomBinding_BlahService"
      contract="BlahServiceReference.BlahService"
      name="CustomBinding_BlahService" /&gt;
  </code></pre>
  
  <p>In the mid-tier there's a similar story with a System.ServiceModel.Dispatcher.IClientMessageInspector decrypting the time stamp and either processing the request or throwing a System.ServiceModel.FaultException with the error message "Invalid stamp".</p>
  
  <p>This follows code examples at <a href="http://msdn.microsoft.com/en-us/library/ms733747.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms733747.aspx</a> and <a href="http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx" rel="nofollow">http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx</a></p>
  
  <p>Now I have changed the mid-tier WCF. Some changes are simple (e.g. correcting a spelling mistake in a method name "retrive" -> "retrieve") while some adds more substantial functionality and I want to update the service recerences in the client. In VS2010 I right-click on the service references that will need updating and select "Update Service Reference". VS2010 connects to the mid-tier WCF ("downloading service information") and then throws the error </p>
  
  <p>The configuration for the service reference could not be updated due to the following issue: The type 'MessageInspectorDLL.MessageInspectorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'MessageInspectorBehavior' could not be loaded. (C:\TFS\Blah\Blah\web.config line 80)</p>
  
  <p>What's wrong? Is there something I need to set up for the update service reference to correctly use the message inspector DLL?</p>
  
  <p>Though it is possible that the DLL or the web.config have errors that seems unlikely since the client will connect to the previous mid-tier which is up on Azure, and that has the same encrypted timestamp inspection.</p>