类型名称或别名xxxx无法解析.请检查您的配置文件并验证此类型名称 [英] The type name or alias xxxx could not be resolved. Please check your configuration file and verify this type name

查看:99
本文介绍了类型名称或别名xxxx无法解析.请检查您的配置文件并验证此类型名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RepositoryPattern项目中定义了以下接口:

I have the following interface defined in a RepositoryPattern project:

using System.Collections.Generic;
using Domain;

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

我的XML配置的统一部分如下:

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:

无法解析类型名称或别名IRepository.请检查您的配置文件并验证此类型名称.

推荐答案

我明白了.我需要添加汇编部分:

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>

这篇关于类型名称或别名xxxx无法解析.请检查您的配置文件并验证此类型名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆