Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer question <strong>a</strong> (sort of) - I do not think there is a "preferred" approach - it really just depends how you want your service to be available. I've hosted net.tcp (I suspect this is the most common in a windows service environment but I am guessing), webhttp, basichttp and wshttp services all fine from inside a windows service. Onto <strong>b</strong>...</p> <p>So the way I do this (and maybe this is just a style thing but it works for me) is that I have a regular windows service and in the program main I bootstrap the container (so stuff that you would do inside App_Start in global asax) and I have installers for the different parts of the application I want to install (incidentally, generally in WCF I split the contracts out into their own assembly and implement them inside the windows service assembly, or in a separate assembly if I need to host the same service in multiple places). </p> <p>Once the container is bootstrapped, I then resolve the ServiceBase from the container and give it to the <a href="http://msdn.microsoft.com/en-us/library/tks2stkt.aspx" rel="nofollow">ServiceBase.Run</a> static method. This way my service can have dependencies on whatever else is registered in the container (this is the only place I would ever call Resolve on the container but I think it is justified in this circumstance). </p> <p>I don't know what else you want your service to do other than hosting WCF services, maybe nothing, but this is a bit of framework to get you going so here it is... </p> <pre><code>static class Program { static void Main() { ServiceBase.Run(CreateContainer().Resolve&lt;ServiceBase&gt;()); } private static IWindsorContainer CreateContainer() { var container = new WindsorContainer(); container.Install(FromAssembly.This()); return container; } } public class ServicesInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) { container .AddFacility&lt;WcfFacility&gt;(f =&gt; { f.CloseTimeout = TimeSpan.Zero; }) .Register( Component .For&lt;IVirusCheckService&gt;() .ImplementedBy&lt;VirusCheckService&gt;() .LifeStyle.Transient .AsWcfService(new DefaultServiceModel() .AddBaseAddresses("http://localhost:8080/MyService") .AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding()) .At("basic")) .PublishMetadata(o =&gt; o.EnableHttpGet())), Component .For&lt;ServiceBase&gt;() .ImplementedBy&lt;MyService&gt;()); } } </code></pre> <p><em>NOTE: The MyService class is just a regular Windows service class (you can use the one visual studio generates for you when you go file | new | windows service if you like) - I have not shown it because it can just be an empty implementation.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload