Note that there are some explanatory texts on larger screens.

plurals
  1. POAutofac and RoutingService
    primarykey
    data
    text
    <p>I am trying to build a routing infrastructure and I use Autofac as IoC container. I read the <a href="http://code.google.com/p/autofac/wiki/WcfIntegration" rel="nofollow">wiki</a> and I know these steps:</p> <pre><code>ContainerBuilder builder = new ContainerBuilder(); builder.Register(c =&gt; new Logger()).As&lt;ILogger&gt;(); builder.Register(c =&gt; new EchoService(c.Resolve&lt;ILogger&gt;())).As&lt;IEchoService&gt;(); using (IContainer container = builder.Build()) { Uri address = new Uri("http://localhost:8080/EchoService"); ServiceHost host = new ServiceHost(typeof(EchoService), address); host.AddServiceEndpoint(typeof(IEchoService), new BasicHttpBinding(), string.Empty); host.AddDependencyInjectionBehavior&lt;IEchoService&gt;(container); host.Description.Behaviors.Add(new ServiceMetadataBehavior {HttpGetEnabled = true, HttpGetUrl = address}); host.Open(); Console.WriteLine("The host has been opened."); Console.ReadLine(); host.Close(); Environment.Exit(0); </code></pre> <p>}</p> <p>I do have this code here to satisfy my scenario:</p> <pre><code>builder.RegisterType&lt;RoutingService&gt;().As&lt;ISimplexDatagramRouter&gt;().InstancePerLifetimeScope(); builder.Register(c =&gt; { var routingConfiguration = new RoutingConfiguration(); routingConfiguration.RouteOnHeadersOnly = false; return routingConfiguration; }).As&lt;RoutingConfiguration&gt;(); builder.Register(c =&gt; { var publisherServiceHost = new ServiceHost(typeof(RoutingService)); publisherServiceHost.AddServiceEndpoint(typeof(ISimplexDatagramRouter), new NetTcpBinding(), "some address"); publisherServiceHost.Description.Behaviors.Add(new RoutingBehavior(c.Resolve&lt;RoutingConfiguration&gt;())); return publisherServiceHost; }).As&lt;ServiceHost&gt;(); </code></pre> <p>This doesn't work, as I get an error from Autofac as it can't find condtructor for RoutingService (its constructor is private).</p> <p>Do you have any hint?</p>
    singulars
    1. This table or related slice is empty.
    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. 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