The type name or alias xxxx could not be resolved. Please check your configuration file and verify this type name

被刻印的时光 ゝ 提交于 2019-12-25 04:11:57

问题


I have the following interface defined in a RepositoryPattern project:

using System.Collections.Generic;
using Domain;

namespace RepositoryPattern
{
    public interface IRepository
    {
        List<Car> GetCars();
    }
}

The unity section of my XML configuartion looks like this:

  <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <namespace name="RepositoryPattern" />
    <container>
      <register type="IRepository" mapTo="SqlServerRepository" />
    </container>
  </unity>

When I run the application, I get the following error:

The type name or alias IRepository could not be resolved. Please check your configuration file and verify this type name.


回答1:


I got it. I needed to add the assembly section:

  <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <assembly name ="RepositoryPattern"/>
    <namespace name="RepositoryPattern" />
    <container>
      <register type="IRepository" mapTo="SqlServerRepository" />
    </container>
  </unity>


来源:https://stackoverflow.com/questions/28771844/the-type-name-or-alias-xxxx-could-not-be-resolved-please-check-your-configurati

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!