【问题标题】:The type name or alias xxxx could not be resolved. Please check your configuration file and verify this type name无法解析类型名称或别名 xxxx。请检查您的配置文件并验证此类型名称
【发布时间】:2015-02-27 18:26:31
【问题描述】:

我在 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.

【问题讨论】:

    标签: asp.net-mvc unity-container


    【解决方案1】:

    我明白了。我需要添加装配部分:

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

    【讨论】:

      猜你喜欢
      • 2015-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-31
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多