How to work with WCF generated proxy with multiple constructors

Jun 17, 2014 at 2:13 PM
Edited Jun 17, 2014 at 2:13 PM

I am using simple injector and very satisfied with it. But i have a bit of an issue with my generated WCF proxy class ( i dont control the service side).

Simple injector complains about too much constructors, what is correct, there are like 5 generated for each service.

I had it working by using RegisterSingle<type)(new instance()), but this ofcourse explodes when my wcf object lands in a faulted state and no new object is created.

Any idea how to get this working? Thx in advance.
Jun 17, 2014 at 2:28 PM
Please read this article about the multiple-constructor anti-pattern and especially the part about framework types and code generators, where it explains:

> Prevent using your container’s auto-wiring facility when registering 3rd party types.

In other words, register your WCF proxy class by hand as follows:
container.Register<ISomeProxy>(() => new MyProxyImplementation(...));
Marked as answer by dot_NET_Junkie on 8/31/2014 at 2:25 PM