views:

35

answers:

0

This is driving me nuts...

Two assemblies/projects in play:

An Infrastructure project, which has an interface in it:

  IDtoMapping<in TDto, out TDomain>

And an app project, referencing Infx, with an implementation:

  PatientMapping : IPatientMapping

...and a marker interface, just to be clear:

  public interface IPatientMapping : IDtoMapping<PatientDTO, Patient> {}

When the app boots, this gets run:

_container.RegisterType<IPatientMapping, PatientMapping> ( new ContainerControlledLifetimeManager () );

This happens in the app project, through a system-wide bootstrapping process. (Immediately after this line runs, (through a watch), I can successfully resolve it.)

Finally, we try to resolve it (in a WCF service, in the app projec)

public PatientService ( 
    IPatientRepository patientRepository, 
    ISessionSource session,
    IPatientMapping patientDtoToDomainMapper )
{

.. and it fails. With the ResolutionFailedException "Cannot instantiate an interface, etc.." I've put break points at the .Resolve call, the registration, etc.. everything is getting hit as expected. But when the app tries to Resolve/BuildUp the WCF Service, Unity can't resolve the IPatientMapping parameter... it's like it forgot.

I'm at a loss.. I upgraded to Unity 2.0, added that intermediate marker interface, removed the generic interface and just used the vanilla one.. all to no avail. Other dependencies in the system resolve just fine, including the other parameters on that same WCF constructor.

The only thing my gut is telling me is could it have something to do with the assemblies? That the .Resolve call is happening in the Infx project, but the implementation actually lives in the app-project? At runtime, all assemblies are loaded, so it shouldn't really matter, right?

Thanks for any ideas!