Adam,

  I believe the problem relates to the open-generic registration.  The Wcf 
Facility waits for the service to be in the ready state before it opens the 
host.  In this case, the container shows the ServiceGenericDependency component 
as waiting for the IDecorator dependency.  It would be nice for the container 
to handle this properly.  I have seen this before and added an option to open 
the service host eagerly.  This will not wait for the component to be reported 
as valid before opening the host.  In your example, it resolved the issue

var wcfFacility=XXXX
wcfFacility.Services.OpenServiceHostsEagerly = true;

cheers,
  craig


On May 7, 2011, at 1:24 AM, Adam Langley wrote:

> Dear Castle groups,
>  
> I have a WCF service which has a single constructor dependency - this 
> dependency is 'generically decorated'.
>  
> i.e. its constructor looks like this:
>  
> public ServiceGenericDependency(IDecorator<IServiceNoDependencies> arg2)
> 
> {
> 
> }
> 
>  
> My 'decorator' constructor looks like this:
> 
> public Decorator(T arg)
> 
> {
> 
> }
> 
> Castle has the typeof(IDecorator<>) registration, and the 
> typeof(IServiceNoDependencies) registered.
> 
> PROBLEM: The WCF Facility fails to create the server.
> IF I add a default constructor to my decorator class, then everything works.
> IF I resolve the WCF service on the server (as a local component, i.e. take 
> WCFFacility out of the equation) then everything works.
> 
> I have included a test program below - just reference WcfFacility + Castle. 
> This is quite an urgent issue for me.
> 
> Thank you!
> 
> using Castle.Windsor;
> using Castle.MicroKernel.Registration;
> using Castle.Facilities.WcfIntegration;
> using System.ServiceModel;
> 
> namespace DecoratorChains
> {
>     class Program
>     {
>         static IWindsorContainer container;
>         static void Main(string[] args)
>         {
>             container = new WindsorContainer()
>                 .AddFacility<WcfFacility>();
> 
>             // this is my decorator, it is capable of decorating any service.
>             
> container.Register(Component.For(typeof(IDecorator<>)).ImplementedBy(typeof(Decorator<>)));
> 
>             container.Register(
>                 
> Component.For<IServiceGenericDependency>().ImplementedBy<ServiceGenericDependency>().LifeStyle.Transient
>                         .AsWcfService(new DefaultServiceModel().AddEndpoints(
>                                 WcfEndpoint.BoundTo(new NetTcpBinding())
>                                     .At("net.tcp://localhost/Operations")
>                                 )
>                         )
>             );
> 
>             // this is my service that WILL BE decorated, then used as a 
> constructor argument.
>             
> container.Register(Component.For<IServiceNoDependencies>().UsingFactoryMethod(()
>  => new ServiceNoDependencies()));
>            
> 
>             var client = 
> ChannelFactory<IServiceGenericDependency>.CreateChannel(
>                 new NetTcpBinding(), new 
> EndpointAddress("net.tcp://localhost/Operations"));
> 
>             // this passes
>             var cc = container.Resolve<IServiceGenericDependency>();
>             
>             // this fails
>             client.DoSomething();
>         }
> 
>     }
> 
>     interface IServiceNoDependencies
>     {
>     }
> 
>     class ServiceNoDependencies : IServiceNoDependencies
>     {
>     }
> 
>     interface IDecorator<T>
>     where T : class
>     {
>     }
> 
>     class Decorator<T> : IDecorator<T>
>         where T : class
>     {
>         /// <summary>
>         /// Remove this constructor and all tests will pass
>         /// </summary>
>         /// <param name="arg"></param>
>         public Decorator(T arg)
>         {
>         }
>     }
> 
>     [ServiceContract]
>     interface IServiceGenericDependency
>     {
>         [OperationContract]
>         void DoSomething();
>     }
> 
>     class ServiceGenericDependency : IServiceGenericDependency
>     {
>         public ServiceGenericDependency(IDecorator<IServiceNoDependencies> 
> arg2)
>         {
>         }
> 
>         public void DoSomething()
>         {
> 
>         }
>     }
> }
> 
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/castle-project-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to