title: Hearing "element 'behavior' has invalid child element" should be ignored, but prevented from updating service reference because of it
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4677377/the-element-behavior-has-invalid-child-element-myfaultextension-in-wcf-app-c">The element ‘behavior’ has invalid child element ‘myFaultExtension’ in wcf app.config</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to implement <a href="http://msdn.microsoft.com/en-us/library/dd470096%28VS.95%29.aspx" rel="nofollow noreferrer">Creating and Handling Faults in Silverlight</a>.  (<a href="http://www.benday.com/2010/08/16/how-to-permanently-banish-silverlights-not-found-error-for-wcf-service-calls/" rel="nofollow noreferrer">This</a> project works on my machine.)</p>
  
  <p>I get a Visual Studio warning:</p>
  
  <blockquote>
    <p>The element 'behavior' has invalid child element 'betterErrorMessagesFaults'.</p>
  </blockquote>
  
  <p>Other answers elsewhere say I should just ignore it, but I can't because I'm not able to update the service reference in the non .Web project (the one with all the xaml files). When I try, I get this error:</p>
  
  <blockquote>
    <p>Parser Error Message: The type 'MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'betterErrorMessagesFaults' could not be loaded.</p>
  </blockquote>
  
  <p>Here's the relevant part of Web.config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;extensions&gt;
      &lt;behaviorExtensions&gt;
        &lt;add name="betterErrorMessagesFaults" 
          type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&gt;
      &lt;/behaviorExtensions&gt;
    &lt;/extensions&gt;
    &lt;services&gt;
      &lt;service name="MyProject.Web.Services.Service2"&gt;
        &lt;endpoint address="" binding="customBinding" 
            bindingConfiguration="MyProject.Web.Services.Service2.customBinding0" 
            contract="MyProject.Web.Services.Service2" 
            behaviorConfiguration="BetterErrorMessagesFaultBehavior"/&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name=""&gt;
          &lt;serviceMetadata httpGetEnabled="true" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
      &lt;endpointBehaviors&gt;
        &lt;behavior name="BetterErrorMessagesFaultBehavior"&gt;
          &lt;betterErrorMessagesFaults/&gt;
        &lt;/behavior&gt;
      &lt;/endpointBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;bindings&gt;
      &lt;customBinding&gt;
        &lt;binding name="MyProject.Web.Services.Service2.customBinding0"&gt;
          &lt;binaryMessageEncoding&gt;
            &lt;readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
              maxDepth="2147483647" maxNameTableCharCount="2147483647" 
              maxStringContentLength="2147483647" /&gt;
          &lt;/binaryMessageEncoding&gt;
          &lt;httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
              maxBufferSize="2147483647" /&gt;
        &lt;/binding&gt;
      &lt;/customBinding&gt;
    &lt;/bindings&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>The <code>BetterErrorMessagesFaultBehavior</code> is just a copy-paste of the class <a href="http://msdn.microsoft.com/en-us/library/dd470096%28VS.95%29.aspx" rel="nofollow noreferrer">here on MSDN</a>; with only the name changed (I tried with default name as well), and the namespace changed to <code>MyProject.Web.Services</code>.</p>
  
  <p>I also tried exchanging</p>
  
  <pre><code>&lt;add name="betterErrorMessagesFaults" 
      type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/&gt;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>&lt;add name="betterErrorMessagesFaults" 
      type="MyProject.Web.Services.BetterErrorMessagesFaultBehavior, MyProject.Web.Services"/&gt;
  </code></pre>
  
  <p>but there was no effect. I read this is extremely sensitive to spaces etc., but I can't see any problem areas. I also looked at the AssemblyInfo and the version is 1.0.0.0, culture is just blank (""), and I don't know what PublicKeyToken is for, but I suspect that is not the problem here...</p>
  
  <p>So I am stumped, no idea where to look next.</p>