views:

321

answers:

2

Hi there,

Is it possible to force WCFSvcHost (which is executed automatically when I do an F5 or when I am debugging another project in the solution) to use a custom ServiceHost?

I have my Custom ServiceHost working great in my asp.net Host container by using a service factory which in turn calls the Custom Service Base.

But when wcfSvcHost executes it's not using my custom ServiceHost.

Is this possible?

If not, what are my alternatives? I presume I must uncheck "Start wcf service host when debugging a project in another solution" which is in the WCF Options in app properties but then I must create a console Host container?

And I can't get the console host container to automatically execute each time I am debugging something else?

I notice this under DEBUG in app properties (maybe I can use something like this to force the loading of the custom servicehost)

       /client:"WcfTestClient.exe"

The problem being is that I have my custom ServiceHost inject some UNITY (IOC) stuff, here the overriden method ... so it must execute otherwise it fails.

    protected override void InitializeRuntime()
    {
        Bootstrapper.ConfigureUnityContainer();
        base.InitializeRuntime();
    }
A: 

I don't think you can do that - you'll need to host in IIS or create your own, customized service host.

marc_s
+1  A: 

Hi,

I was trying exactly the same thing for exactly the same purpose (;-)

I thought I found a solution by not using physical .svc files anymore (which contain the custom host factory when hosting in IIS), but moving this info to the .config file instead:

<serviceHostingEnvironment aspNetCompatibilityEnabled="false">
  <serviceActivations>
    <add relativeAddress="~/Services/NaisTime/NaisTimeService.svc" service="Nais.Time.Services.NaisTime.NaisTimeService"
      factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
    <add relativeAddress="~/Services/Northwind/NorthwindService.svc" service="Nais.Time.Services.Northwind.NorthwindService"
      factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
  </serviceActivations>
</serviceHostingEnvironment>

It works for IIS, but putting the same entries in the app.config file of my Service Library project does not make SvcWcfHost use this.

I guess I am not getting my relativeAddress right.

Anybody any experience with this?

kr, Michel Liesmons.

michel