{
}
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 castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
Thanks for that - I will give it a try ASAP.
I thought it might be something like this - I noticed that when I forced a local resolution to occur, then a final 'ComponentRegistered' event was fired, which reported a 'closed generic' component... specialized to the generic argument (so in this case, IDecorator<IServiceNoDependencies>) - but it was not added to the list of 'registered components'.
I dont know enough about Castle to comprehend what kind of lifecycle is going on under the hood - it would be ideal if the WCF facility was able to open hosts for these components without 'eager' resolution.
Thanks for the help Craig,
Adam Langley
Please consider the environment before printing this email!
Can you provide a failing test with the reproduction
it's in the doco:
http://docs.castleproject.org/How-to-submit-a-fix-to-any-Castle-Project.ashx
Krzysztof
I added an ignore test to demonstrate the problem with open-generics. It is just Adams example for the most part.
Best regards
Adam Langley
Sent from my iPhone