I have a basic class that is trying to resolve an interface using Unity.
IUnityContainer containter = new UnityContainer();
containter.RegisterType<IRepositoryFactory>();
IRepositoryFactory repositoryFactory = containter.Resolve<IRepositoryFactory>();
My config file is as follows:
<unity>
<containers>
<container>
<types>
<type name="IRepositoryFactory"
type="QuinntyneBrown.Interfaces.IRepositoryFactory"
mapTo="QuinntyneBrown.Photography.Factories.RepositoryFactory" />
</types>
</container>
</containers>
</unity>
I'm getting the following error:
Resolution of the dependency failed, type = "QuinntyneBrown.Interfaces.IRepositoryFactory", name = "(none)". Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, QuinntyneBrown.Interfaces.IRepositoryFactory, is an interface 开发者_如何学Goand cannot be constructed. Are you missing a type mapping?
At the time of the exception, the container was:
Resolving QuinntyneBrown.Interfaces.IRepositoryFactory,(none)
containter.RegisterType<IRepositoryFactory>();
This doesn't make any binding. Load bindings from your config file instead:
containter.LoadConfiguration();
精彩评论