Q:

Cant get WCF extension to register

I am pretty new to wcf and am trying to get a wcf extension to register and so I can ultimatly open/close an NHibernate session.
However I followed the details at Adam Matusiaks blog. I had to make a few guesses as it didnt compile first time. (NHibernateEndpointExtension : IExtension this iheritance had no type inthe example).
It just wont register the extension. When I make the wcf call it has no extensions in the collection. 
There are no error messages and nothing is appearing in any logs I can see
DOES ANYONE KNOW WHERE I CAN LOOK AT SOME LOGGING Or anything 
My web.config is as follows
  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="NHibernateExtension" type="SMS.Infrastructure.NHibernateEndpointExtension, SMS.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
    <bindings>
      <basicHttpBinding>
        <binding name="AmjBasicHttpEndpointBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="AmjWsBinding">
          <security>
            <transport proxyCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SMS.Services.BEIMBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <!-- set thsi to false if you dont want helpfult stack traces-->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="SMS.Services.BEIMBehavior" name="SMS.Services.BEIM">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="AmjWsBinding"
          name="BeimServices" contract="SMS.Services.IBEIM">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

  </system.serviceModel>

The classes that I am using are a s follows, I've got rid of the nhibernate stuff for now as I can deal with that when the extension is registered
namespace SMS.Infrastructure
{

    public class NHibernateEndpointExtension : IExtension<OperationContext>
    {
        public NHibernateEndpointExtension()
        {
        }

        public NHibernate.ISession NHibernateSession{ get; set; }
        public void Attach(OperationContext owner)
        {
        }

        public void Detach(OperationContext owner)
        {
        }
    }

    public class NHibernateEndpointContextInitializer : ICallContextInitializer
    {
        public object BeforeInvoke(InstanceContext instanceContext, IClientChannel channel, Message message)
        {
            bool found = false;
            foreach (IExtension<OperationContext> extension in OperationContext.Current.Extensions)
            {
                if (extension is NHibernateEndpointExtension)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                OperationContext.Current.Extensions.Add(new NHibernateEndpointExtension());
            }
            return NHibernateWcfSessionProvider.Instance.OpenSession();

        }

        public void AfterInvoke(object correlationState)
        {
            NHibernateWcfSessionProvider.Instance.CloseSession(((NHibernate.ISession)correlationState));
            ((IDisposable)correlationState).Dispose();

        }
    }

    public class NHibernateEndpointBehavior : BehaviorExtensionElement, IEndpointBehavior

    {

        public override Type BehaviorType
        {
            get { return typeof(NHibernateEndpointBehavior); }
        }

        protected override object CreateBehavior()
        {
            return new NHibernateEndpointBehavior();
        }

        public void Validate(ServiceEndpoint endpoint)
        {
        }

        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {
        }

        public void ApplyDispatchBehavior(ServiceEndpoint endpoint,
            EndpointDispatcher endpointDispatcher)
        {
            foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations)
            {
                operation.CallContextInitializers.Add(new NHibernateEndpointContextInitializer());
            }
        }

        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
        }
    }

    public class NHibernateWcfSessionProvider
    {

        public NHibernateWcfSessionProvider()
        {

        }

        private static NHibernateWcfSessionProvider instance;

        public static NHibernateWcfSessionProvider Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new NHibernateWcfSessionProvider();
                }
                return instance;
            }
        }

        private ISessionFactory sessionFactory;

        public void CreateSessionFactory()
        {
            sessionFactory= NHibernateHelper.CreateSessionFactory();
        }

        public NHibernate.ISession GetSession()
        {
            // get Nhibernate session from OperationContext or HttpContext
            return ISession // just here to show that a session will be returned
        }

        public NHibernate.ISession OpenSession()
        {
            // get Nhibernate session from OperationContext or HttpContext
            return ISession // just here to show that a session will be returned
        }

        public void CloseSession()
        {
            CloseSession(null);
        }

        public void CloseSession(NHibernate.ISession session)
        {
            ///Closes NHibernate session cleanly
         }

    }

A:

I haven't really tried to execute this, so there might be more issues than shown below, please bear with me.
It looks like you only registered the behavior extension (using the system.serviceModel\extensions\behaviorExtensions\add element). You also need to add it to a binding configuration by adding the respective element (by the name you specified when registering). In your case that should be:
<behaviors>
  <serviceBehaviors>
  ...
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="MyEpBehavior">
      <!-- ... possibly other stuff ... -->
      <NHibernateExtension/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="SMS.Services.BEIMBehavior" name="SMS.Services.BEIM">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="AmjWsBinding"
      name="BeimServices" contract="SMS.Services.IBEIM"
      configuration="MyEpBehavior"> <!-- SET ENDPOINT BEHAVIOR -->
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

From your question it is not certain whether you tried, but when troubleshooting the WCF mechanics, it is usually quite helpful to enable WCF tracing - although I'm not sure if it would have to say anything about this particular issue.

