Trying to set up Unity via XML configurations I'm getting this exception
The type name or alias ServiceHost could not be resolved. Please check your configuration file and verify this type name.
Trying to comment that out I get the same exception for the next and then the next after that so the problem must lie somewhere in my setup.
<unity>
<typeAliases>
<!-- Lifetime manager types -->
<typeAlias alias="singleton"
type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
Microsoft.Practices.Unity" />
<typeAlias alias="external"
type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
Microsoft.Practices.Unity" />
<typeAlias alias="perThread"
type="Microsoft.Practices.Unity.PerThreadLifetimeManager,
Microsoft.Practices.Unity" />
<!-- User-defined type aliases -->
<typeAlias alias="ServiceHost"
type="System.ServiceModel.ServiceHost, System.ServiceModel" />
<typeAlias alias="UnityServiceHost"
type="MyProjectServiceLibrary.Hosting.UnityServiceHost" />
<typeAlias alias="IServiceBehavior"
type="System.ServiceModel.Descriptions.IServiceBehavior, System.ServiceModel" />
<typeAlias alias="UnityServiceBehavior"
type="MyProjectServiceLibrary.Hosting.UnityServiceBehavior, MyProjectServiceLibrary" />
<typeAlias alias="IInstanceProvider"
type="System.ServiceModel.Dispatcher.IInstanceProvider, System.ServiceModel" />
<typeAlias alias="UnityInstanceProvider"
type="MyProjectServiceLibrary.Hosting.UnityInstanceProvider, MyProjectServiceLibrary" />
<typeAlias alias="MyProjectService"
type="MyProjectServiceLibrary.Service.MyProjectService, MyProjectServiceLibrary" />
<typeAlias alias="IRepositoryFactory"
type="MyProjectDataModelLibrary.Repository.IRepositoryFactory, MyProjectDataModelLibrary" />
<typeAlias alias="RepositoryFactory"
type="MyProjectDataModelLibrary.Repository.RepositoryFactory, MyProjectDataModelLibrary" />
<typeAlias alias="IDbContext"
type="MyProjectDataModelLibrary.DataContext.IDbContext, MyProjectDataModelLibrary" />
<typeAlias alias="MyProjectDatabase"
type="MyProjectDataModelLibrary.DataContext.MyProjectDatabase, MyProjectDataModelLibrary" />
<typeAlias alias="IRepositoryOfT"
type="MyProjectDataModelLibrary.Repository.IRepository`1, MyProjectDataModelLibrary" />
<typeAlias alias="EntityRepositoryOfT"
type="MyProjectDataModelLibrary.Repository.EntityRepository`1, MyProjectDataModelLibrary" />
</typeAliases>
<containers>
<container>
<types>
<type type="MyProjectService" />
<type type="ServiceHost"
mapTo="UnityServiceHost" />
<type type="IServiceBehavior"
mapTo="UnityServiceBehavior" />
<type type="IInstanceProvider"
mapTo="UnityInstanceProvider" />
<type type="IRepositoryFactory"
mapTo="RepositoryFactory" />
<type type="IDbContext"
mapTo="MyProjectDatabase" />
<type type="IRepositoryOfT"
mapTo="EntityRepositoryOfT" />
</types>
</container>
</containers>
</unity>
I've tried reading around to see what I'm doing wrong. I doubt it's the fully qualified name though I can't be sure as I haven't really used that before.
IUnityContainer container = new UnityContainer();
container.RegisterInstance<IUnityContainer>(container);
UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
section.Configure(container);
The exception is thrown in the last line here.