You are on the right track but just need a couple of tweaks.

1) When you use AsWcfService() instead of passing in a parameter it will 
read from the app.config.

Example from the Castle  unit tests:

using (new WindsorContainer()
.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero)
.Register(Component.For<UsingWindsor>()
.DependsOn(new { number = 42 })
.AsWcfService()
))
{
var client = ChannelFactory<IAmUsingWindsor>.CreateChannel(
new BasicHttpBinding(), new 
EndpointAddress("http://localhost:27198/UsingWindsor.svc";));
Assert.AreEqual(42, client.GetValueFromWindsorConfig());
}

2)  I recall running into your specific issue before and I believe I have 
to name the service in the app.config the service contract name, so in your 
case make "name" and "contract" both "Foo.IAuthenticationService" and then 
give it a try.

On Wednesday, February 11, 2015 at 9:55:52 AM UTC-7, Scott_M wrote:
>
> Is it possible to use Castle to self host a WCF service but use all the 
> WCF endpoint/binding info from app.config (as oppossed to setting in code 
> via DefaultServiceModel)?
>
> Are there any good examples of this?
>
> I tried the following but got InvalidOperationException
>
> //code          
> container.AddFacility<WcfFacility>();
> ..
> ..
> container.Register(
>                 Component.For<IAuthenticationService>()
>                          .ImplementedBy<AuthenticationService>()
>                          .Named("AuthenticationService") 
>                          .AsWcfService()
>                          .LifestyleTransient()
>                 );
>
> //config 
>   <system.serviceModel>
>     <services>
>       <service name="AuthenticationService">
>         <endpoint name ="AuthenticationService_NetTcp" 
> address="net.tcp://localhost:9872/authenticationservice.svc" 
> binding="netTcpBinding" contract="Foo.IAuthenticationService" />
>       </service>
>     </services>  
>   </system.serviceModel>
>
> //exception
> AuthenticationService' has zero application (non-infrastructure) 
> endpoints. This might be because no configuration file was found for your 
> application, or because no service element matching the service name could 
> be found in the configuration file, or because no endpoints were defined in 
> the service element.
>
> .Net 3.5
> Castle 3.3.0
> Windows 2012
>
> thanks
>
> scott
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to