Unity 2.0: how to resolve constructor dependencies
===

I have an **IRequestManager** class that resolves to the **RequestManager** class, but I am getting System.IO.FileLoadException was unhandled by user code Message=The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)


    public class RequestManager : IRequestManager
    {
        private IRepository<Request> _requestRepository;
        public RequestManager(IRepository<Request> requestRepository)
        {
            _requestRepository = requestRepository;
        }
        // ...
    }

I am having trouble registering IRequestManager in my web.config; do I need to create explicitly register IRepository<Request> in the web.config?

Here is my web.config

    <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
        <alias alias="PerOperationContext" type="UnityWcfExtensions.UnityOperationContextLifetimeManager, UnityWcfExtensions" />
        <container>
          <register type="MRF.Repository.IDbContext, MRF.Repository" mapTo="MRF.Repository.EntityFrameworkCodeFirst.MRFDbContext, MRF.Repository.EntityFrameworkCodeFirst">
            <lifetime type="PerOperationContext" />
            <constructor>
              <param name="nameOrConnectionString" value="MRFContext" type="string" />
            </constructor>
          </register>
    
          <register type="MRF.Repository.IUnitOfWorkFactory, MRF.Repository" mapTo="MRF.Repository.EntityFrameworkCodeFirst.MRFDbContext, MRF.Repository.EntityFrameworkCodeFirst">
            <lifetime type="PerOperationContext" />
            <constructor>
              <param name="nameOrConnectionString" value="MRFContext" type="string" />
            </constructor>
          </register>
    
          <register type="MRF.Repository.IRepository`1, MRF.Repository" mapTo="MRF.Repository.EntityFrameworkCodeFirst.GenericRepository`1, MRF.Repository.EntityFrameworkCodeFirst" />
          <register type="MRF.Business.Interfaces.IRequestManager, MRF.Business.Interfaces" mapTo="MRF.Business.RequestManager, MRF.Business">
            <constructor>
              <param name="requestRepository" type="MRF.Repository.IRepository`1[[MRF.Entities.Request, MRF.Entities]]">
                <dependency />
              </param>
            </constructor>
            
          </register>
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.Region, MRF.Entities],[MRF.Service.DataContract.Region, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.RegionMapper, MRF.Mapping.AutoMapper" />
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.User, MRF.Entities],[MRF.Service.DataContract.User, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.UserMapper, MRF.Mapping.AutoMapper" />
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.UserPreference, MRF.Entities],[MRF.Service.DataContract.UserPreference, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.UserPreferenceMapper, MRF.Mapping.AutoMapper" />
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.Status, MRF.Entities],[MRF.Service.DataContract.Status, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.StatusMapper, MRF.Mapping.AutoMapper" />
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.Request, MRF.Entities],[MRF.Service.DataContract.Request, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.RequestMapper, MRF.Mapping.AutoMapper" />
          <register type="MRF.Mapping.IMapper`2[[MRF.Entities.Series, MRF.Entities],[MRF.Service.DataContract.Series, MRF.Service.DataContract]], MRF.Mapping" mapTo="MRF.Mapping.AutoMapper.SeriesMapper, MRF.Mapping.AutoMapper" />
        </container>
      </unity>


My current work around is to manually create a new instance of RequestManager in my WCF service and pass in the resolved constructor parameters as shown below:

    public DC.Request GetRequest(int requestId)
    {
        var requestRepository = this.Container.Resolve<IRepository<BE.Request>>();
        var requestManager = new RequestManager(requestRepository);
        var request = requestManager.GetRequest(requestId);
        var userMapper = this.Container.Resolve<IMapper<BE.User, DC.User>>();
        var seriesMapper = this.Container.Resolve<IMapper<BE.Series, DC.Series>>();
        var statusMappger = this.Container.Resolve<IMapper<BE.Status, DC.Status>>();
        var mapper = this.Container.Resolve<IMapper<BE.Request, DC.Request>>();
        return mapper.Map(request);
    }
