Autofac.Configuration 3.3.0不稳定
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不稳定的更多相关文章
- 未能加载文件或程序集“Autofac, Version=3.4.0.0,
遇到这个错误的时候:如下图 未能加载文件或程序集“Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da” ...
- Squid configuration directives 3.0
WELCOME TO SQUID 3.0.STABLE25-20100412 ---------------------------- This is the default Squid config ...
- .net core 2.0 Autofac
参考自 https://github.com/VictorTzeng/Zxw.Framework.NetCore 安装Autofac,在`project.csproj`加入 <PackageRe ...
- Autofac Mvc5 Nuget
Autofac 3.5.2 Install-Package Autofac -Version 3.5.2 Autofac ASP.NET MVC 5 Integration 3.3.3 Install ...
- Package Manager Console的使用
Find-Package PM> Find-Package autofac https://docs.microsoft.com/en-us/nuget/tools/ps-ref-find-pa ...
- 06、NetCore2.0依赖注入(DI)之整合Autofac
06.NetCore2.0依赖注入(DI)之整合Autofac 除了使用NetCore2.0系统的依赖注入(DI)框架外,我们还可以使用其他成熟的DI框架,如Autofac.Unity等.只要他们支持 ...
- ASP.NET Core 整合Autofac和Castle实现自动AOP拦截
前言: 除了ASP.NETCore自带的IOC容器外,我们还可以使用其他成熟的DI框架,如Autofac,StructureMap等(笔者只用过Unity,Ninject和Castle). 1.ASP ...
- Autofac 依赖注入
介绍 Autofac是一款IOC框架,很轻量级性能非常高,自动注入很给力. NuGet Autofac:Autofac控制反转容器核心 Autofac.MVC5:提供IDependencyResolv ...
- C#开发微信门户及应用(42)--使用Autofac实现微信接口处理的控制反转处理
在很多情况下,我们利用IOC控制反转可以很方便实现一些接口的适配处理,可以在需要的时候切换不同的接口实现,使用这种方式在调用的时候,只需要知道相应的接口接口,具体调用哪个实现类,可以在配置文件中动态指 ...
随机推荐
- 操作SSIS之前的准备工作
SSIS的历史概述: 在SQL Server7.0中,微软成立了一个很小的开发团队开发SQL Server中一个非常低调的功能,该功能被称为DTS(数据转换服务),该功能一直被沿用到SQL2000. ...
- degign new theme for Filezilla(Mac OS X)
the theme directory is located at Filezilla.app/Contents/SharedSupport/resources/ the dirs (excludin ...
- maven常见错误
摘要: 1.Java-maven异常-cannot be cast to javax.servlet.Filter 报错 tomcat 启动后先将tomcat/lib目录下的jar包全部读入内存,如 ...
- WPF:设置弹出子菜单的是否可用状态及效果
需求: 设置弹出子菜单(二级)项仅首项可用,其他项均不可用:不可用是呈灰色效果. 注: 菜单项都是依据层级数据模板.具体格式如下: StackBlock{TextBlock{Image}.TextBl ...
- windows进程详解
1:系统必要进程system process 进程文件: [system process] or [system process]进程名称: Windows内存处理系统进程描述: Windows ...
- osip状态机分析
转载于:http://blog.csdn.net/lbc2100/article/details/48342889 OSIP的核心是系统状态机,在不同情况下,系统处于不同的状态,在某一状态下当系统发生 ...
- java正则表达式的使用
姿势: Pattern pattern = Pattern.compile("^Java.*");Matcher matcher = pattern.matcher("J ...
- storm配置项目
java.library.path: “/usr/local/lib:/opt/local/lib:/usr/lib”### storm.* configs are general configura ...
- Android 获取全部应用
package com.lvshandian.menshen.download;import android.content.Context;import android.content.Inte ...
- 制作登录界面,登录成功后把用户名放在session里,在第3个页面读取session显示用户名
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...