Why do I get an error “configuration evaluation context not found” when I try to create a custom binding using bindings or binding elements from a library?

The evaluation context not found error (or in traces with the identifier System.ServiceModel.EvaluationContextNotFound) is generally caused by using a configuration element defined in a library that is not included in the application’s configuration as an extension. Depending on how the configuration is being used you might instead get a more helpful message directing you to check the configuration extensions section.

When you use a custom configuration element in another assembly, you need to register the extension that defines the configuration element with the configuration system. That would look something like this:

<configuration>
  <system.serviceModel>
    <extensions>
      <bindingExtensions>
        <add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
    </extensions>
  </system.serviceModel>
</configuration>

I’ve used one of our binding extensions added in Orcas as an example. There are a variety of different extension sections for items such as bindings, binding elements, and behaviors. I talked about the use of strong names in configuration extension references in the past if this pains you during development.

In .Net 4 Beta 1 you might get this error despite having properly registered the extension in configuration. That’s because there is a bug that causes the registered extensions to not be handled properly when reading a configuration file other than the one for the current application. This will be fixed in the next beta and isn’t a problem in any of the past releases.