views:

262

answers:

1

Hi,

I'm having issues with my WCF service. I need to do a windsor container injection pre application_start and noticed I can use the AppInitialise method. It works on visual studio debug but when I deploy to IIS the code does not get fired.. I initialized the class as follows

public static class Class1
{
    public static void AppInitialize()
    {
        IWindsorContainer container;
        container = new WindsorContainer("windsor.xml");
        container.AddFacility<WcfFacility>();
        container.Resolve<ProfileLookUpService>();
    }
}

Is there any special task I need to do to get this to work on IIS. I'm using version 6.

Thanks!

A: 

Well, you need to be aware of several things:

  • a WCF service could be self-hosted - it's not always hosted in IIS, so don't rely on a IIS-specific mechanism, if ever possible

  • a WCF service on the server-side basically consists of a ServiceHost (or a custom descendant thereof), which initializes the WCF runtime, and it will create service class instances as needed to handle the requests

So it really depends on where you want to inject your stuff - my gut feeling would tell me you're probably interested in the ability to create a custom ServiceHost descendant, and hook into some of its methods and events to handle your initialization.

Check out some really good articles and blog post on the topic here:

marc_s