我在RepositoryPattern项目中定义了以下接口:
using System.Collections.Generic;
using Domain;
namespace RepositoryPattern
{
public interface IRepository
{
List<Car> GetCars();
}
}
我的XML配置的统一部分如下所示:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<namespace name="RepositoryPattern" />
<container>
<register type="IRepository" mapTo="SqlServerRepository" />
</container>
</unity>
运行应用程序时,出现以下错误:
The type name or alias IRepository could not be resolved. Please check your configuration file and verify this type name.
答案 0 :(得分:2)
我明白了。我需要添加汇编部分:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<assembly name ="RepositoryPattern"/>
<namespace name="RepositoryPattern" />
<container>
<register type="IRepository" mapTo="SqlServerRepository" />
</container>
</unity>