Autofac.Configuration程序集的作用:通过配置来实现依赖注入。

示例:

1.配置内容

<configuration>
  <configSections>
    <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/>
  </configSections>
  <autofac defaultAssembly="MyAutofac.Services">
    <components>
      <component type="MyAutofac.Services.SqlDatabase, MyAutofac.Services"
                 service="MyAutofac.Services.IDatabase"/>
    </components>
  </autofac>
</configuration>

2.代码调用

[TestMethod]
        public void SelectThirdTest()
        {
            var builder = new ContainerBuilder();
            builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
            ////通过Lampda表达式注册DatabaseManager实例
            builder.Register(c => new DatabaseManager(c.Resolve<IDatabase>()));
            string result = null;
            using (var container = builder.Build())
            {
                var manager = container.Resolve<DatabaseManager>();
                result = manager.Search("SELECT * FORM USER");
            }
            Assert.IsNotNull(result);
        }

问题:

在使用过程中,通过Nuget获取最新的稳定版本Autofac.Configuration3.3.0和Autofac3.5.2,却不能正常运行。

过程描述如下:

1.使用Autofac.Configuration 3.3.0时,参考https://www.nuget.org/packages/Autofac.Configuration/3.3.0中的说明,

Dependencies[Autofac (≥ 3.3.1 && < 4.0.0)],因此使用最新的Autofac 3.5.2。编译通过,但实际运行时,会提示缺乏对Autofac 3.3.0的引用。
2.将Autofac 3.5.2替换为Autofac 3.3.0,编译报错。

3.将Autofac.Configuration 3.3.0替换为Autofac.Configuration 3.2.0,编译通过,运行通过。

Demo下载 http://download.csdn.net/detail/heoo442/9134319

Autofac.Configuration 3.3.0不稳定的更多相关文章

  1. 未能加载文件或程序集“Autofac, Version=3.4.0.0,

    遇到这个错误的时候:如下图 未能加载文件或程序集“Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da” ...

  2. Squid configuration directives 3.0

    WELCOME TO SQUID 3.0.STABLE25-20100412 ---------------------------- This is the default Squid config ...

  3. .net core 2.0 Autofac

    参考自 https://github.com/VictorTzeng/Zxw.Framework.NetCore 安装Autofac,在`project.csproj`加入 <PackageRe ...

  4. Autofac Mvc5 Nuget

    Autofac 3.5.2 Install-Package Autofac -Version 3.5.2 Autofac ASP.NET MVC 5 Integration 3.3.3 Install ...

  5. Package Manager Console的使用

    Find-Package PM> Find-Package autofac https://docs.microsoft.com/en-us/nuget/tools/ps-ref-find-pa ...

  6. 06、NetCore2.0依赖注入(DI)之整合Autofac

    06.NetCore2.0依赖注入(DI)之整合Autofac 除了使用NetCore2.0系统的依赖注入(DI)框架外,我们还可以使用其他成熟的DI框架,如Autofac.Unity等.只要他们支持 ...

  7. ASP.NET Core 整合Autofac和Castle实现自动AOP拦截

    前言: 除了ASP.NETCore自带的IOC容器外,我们还可以使用其他成熟的DI框架,如Autofac,StructureMap等(笔者只用过Unity,Ninject和Castle). 1.ASP ...

  8. Autofac 依赖注入

    介绍 Autofac是一款IOC框架,很轻量级性能非常高,自动注入很给力. NuGet Autofac:Autofac控制反转容器核心 Autofac.MVC5:提供IDependencyResolv ...

  9. C#开发微信门户及应用(42)--使用Autofac实现微信接口处理的控制反转处理

    在很多情况下,我们利用IOC控制反转可以很方便实现一些接口的适配处理,可以在需要的时候切换不同的接口实现,使用这种方式在调用的时候,只需要知道相应的接口接口,具体调用哪个实现类,可以在配置文件中动态指 ...

随机推荐

  1. mysql中and和or

    and的优先级高于or,所以一个sql语句中如果and和or同时出现,则or要加括号

  2. Python—I/O多路复用

    一.I/O多路复用概念: 监听多个描述符的状态,如果描述符状态改变,则会被内核修改标志位,从而被进程获取进而进行读写操作 二.select,poll,epoll select模块,提供了:select ...

  3. js与jsp

    jsp :j2ee 中的一样模版技术,运行于服务器端javascript :一种运行于客户端的脚本语言,动态性.JavaScript是一种采用事件驱动的脚本语言,它不需要经过Web服务器就可以对用户的 ...

  4. solr 4.6配置正解

    最近在学习solr,可是在网上找了很多个配置的资料,要不就是solr版本不对,反正各种问题.最后终于出来了,在这里给大家分享一下 1.准备工作 我们要先去下载一个tomcat,我下载的版本是tomca ...

  5. JS闭包导致循环给按钮添加事件时总是执行最后一个

    加入如下脚本代码: <script> var list_obj = document.getElementsByTagName('li'); for (var i = 0; i <= ...

  6. treegrid and datagrid ctrl or shift selectRow

    var tg = $('#tg');tg.treegrid({...}); // create treegridvar panel = tg.treegrid('getPanel');var body ...

  7. 关于JS中apply方法的基本理解

    最近研究OpenLayers源码时,发现其中使用了比较多的apply方法,对其也是很不明白.于是上网经过多方面了解以及自己细细体会后,终于算是基本明白是其干什么的了,这里分享下.apply方法的造型是 ...

  8. C语言复杂声明

    C语言复杂声明 First step int *f(); /* f:是一个函数,它返回一个指向int类型的指针*/ int (*pf)(); /* pf:是一个指向函数的指针,该函数返回一个int类型 ...

  9. Deep Learning 13_深度学习UFLDL教程:Independent Component Analysis_Exercise(斯坦福大学深度学习教程)

    前言 理论知识:UFLDL教程.Deep learning:三十三(ICA模型).Deep learning:三十九(ICA模型练习) 实验环境:win7, matlab2015b,16G内存,2T机 ...

  10. python3 字符串相关函数

    python版本 3.5 #Author by Liguangbo#_*_ coding:utf-8 _*_str="i like study python, welcome to my p ...