I have the following code :
using System.Web.Http;
using Coben.DataAccess.Tests.Constructiv.CentralDB.Contracts.ServiceContracts;
using Coben.Person.DataAccess;
using Constructiv.CentralDB.Contracts.ServiceContracts;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Unity.WebApi;
namespace CoBen.UI
{
public static class UnityConfig
{
public static void RegisterComponents()
{
var container = new UnityContainer();
container.RegisterInstance<IPersonService>(new PersonServiceMock().Mock);
container.RegisterType<PersonRepository>();
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
}
}
This configures my dependency injection. But I would like to do the same from my web.config.
i have the following :
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<alias alias="IPersonService" type="Constructiv.CentralDB.Contracts.ServiceContracts.IPersonSercice, Constructiv.CentralDB.Contracts.ServiceContracts" />
<namespace name="Coben.DataAccess.Tests.Constructiv.CentralDB.Contracts.DataContracts.Persons" />
<assembly name="Coben.DataAccess.Tests.Constructiv.CentralDB.Contracts.DataContracts.Persons" />
<container>
<register type="IPersonService" name="special" mapTo="PersonServiceMock().Mock" />
</container>
But when i do it like this I get an error message :
The type name or alias IPersonService could not be resolved. Please check your configuration file and verify this type name.
What am I doing wrong or what am I not seeing ?
Update: I know get the following error : The type name or alias Constructiv.CentralDB.Contracts.ServiceContracts.IPersonService, Constructiv.CentralDB.Contracts.ServiceContracts could not be resolved. Please check your configuration file and verify this type name.
My config looks as follows:
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
</configSections>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="Constructiv.CentralDB.Contracts.ServiceContracts.IPersonService, Constructiv.CentralDB.Contracts.ServiceContracts"
mapTo="Coben.DataAccess.Tests.Constructiv.CentralDB.Contracts.DataContracts.Persons.PersonServiceMock().Mock, Coben.DataAccess.Tests.Constructiv.CentralDB.Contracts.DataContracts.Persons" />
</container>