Forcing WcfSvcHost.exe to use my custom service host

旧城冷巷雨未停 提交于 2019-12-10 09:31:27

问题


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 ustom service?

I have my custom service host 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 ustom service.

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();
}

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1543327/forcing-wcfsvchost-exe-to-use-my-custom-service-host

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!