none
How to ensure that an extension is loaded? RRS feed

  • Question

  • Hi,

    I have created an Error handler (IErrorHandler, IServiceBehavior) extension and a Message inspector (IDispatchMessageInspector, IEndpointBehavior) extension for my WCF service. It is very important that these extensions are loaded. So I want to throw an exception in ServiceHostFactory.CreateServiceHost if they aren't loaded. But I can't find the things in the host created there...any pointers?

    -- 
    Werner

    Friday, February 7, 2014 12:07 PM

Answers

  • Hi,

    Try this:

    ServiceDebugBehavior sdb = myServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
    try{
    if (sdb !== null)
    {
         myServiceHost.Description.Behaviors.Add(sdb);
     
    }
     }catch(exception e){
     
      Console.WriteLine("The extension is not loaded");
      Console.ReadLine();
    
    }
       

    Thanks.
    • Marked as answer by Werner Clausen Monday, February 10, 2014 10:48 AM
    Monday, February 10, 2014 8:57 AM

All replies

  • Hi,

    Try this:

    ServiceDebugBehavior sdb = myServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
    try{
    if (sdb !== null)
    {
         myServiceHost.Description.Behaviors.Add(sdb);
     
    }
     }catch(exception e){
     
      Console.WriteLine("The extension is not loaded");
      Console.ReadLine();
    
    }
       

    Thanks.
    • Marked as answer by Werner Clausen Monday, February 10, 2014 10:48 AM
    Monday, February 10, 2014 8:57 AM
  • Under "Description" yes :)

    Thanks!

    Monday, February 10, 2014 10:49 AM