autofac

Autofac, upgrade to version 4.0.0 is missing ConfigurationSettingsReader

梦想的初衷 提交于 2019-12-01 20:49:18
The latest documentation still refer's to the ConfigurationSettingsReader class which seems to be missing from the updated Autofac.Configuration assembly. How do get the equivalent of this code to function in version 4.0.0. I have this configuration: <section name="dependencies" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" /> ... <dependencies> <modules> <module type="MyModule, MyAssembly.Service" /> </modules> </dependencies> and this code. // register the application overrides. container.RegisterModule(new ConfigurationSettingsReader("dependencies")); additionally, the

net core 3.0 与Autofac

蓝咒 提交于 2019-12-01 18:35:31
首先需要nuget引入包 using Autofac; using Autofac.Extensions.DependencyInjection; public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public static IContainer AutofacContainer; //定义autofac容器 // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //注册数据库Gwglxs services.AddDbContext<GwglxsDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("GwglxsConnection") )//.UseLazyLoadingProxies()

Autofac and ASP .Net MVC 4 Web API

北战南征 提交于 2019-12-01 16:22:00
I am using Autofac for IoC in my ASP .Net MVC 4 project. Autofac is having some trouble initializing the repository and passing it to the API Controller . I am sure I am missing something in my configuration. Here is the error I get when I navigate to: https://localhost:44305/api/integration <Error> <Message>An error has occurred.</Message> <ExceptionMessage> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'EL.Web.Controllers.API.IntegrationController' can be invoked with the available services and parameters: Cannot resolve parameter

FileLoadException: Could not load file or assembly in WebRole (recycling instance)

与世无争的帅哥 提交于 2019-12-01 14:29:31
My WebRole won't start but keeps restarting and throws this exception: Application: WaIISHost.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException: Could not load file or assembly 'Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' at MyDomain

Using Autofac with ASP.NET and the MVP pattern

早过忘川 提交于 2019-12-01 13:17:19
I'm trying to integrate Autofac into an exsisting ASP.NET web application. The pages follow the MVP pattern. Each page implements a View and delegate functionality to a Presenter. The View is injected into the Presenter thru the constructor. I was able to register the Presenter and View and the page loads fine but when a postback happens the user controls on the view are null. It seems that Autofac creates a new instance of the Page to give to the presenter instead of giving it the instance real Page instance. Is there a way to have Page instances registered with Autofac? Has anyone use

FileLoadException: Could not load file or assembly in WebRole (recycling instance)

雨燕双飞 提交于 2019-12-01 12:53:15
问题 My WebRole won't start but keeps restarting and throws this exception: Application: WaIISHost.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException: Could not load file or assembly 'Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT:

【Autofac打标签模式】AutoConfiguration和Bean

前提是你 提交于 2019-12-01 12:24:02
支持的标签一览 标签名称 使用位置 使用说明 AutoConfiguration 打在class上面 自动装配class里面带有Bean标签的方法 Bean 打在方法上面 配合AutoConfiguration标签使用 Component 打在class上面 自动注册 Autowired 打在构造方法的Parameter,类的Property,类的Field 自动装配 PropertySource 打在class上面 配合Value标签使用,设置Value的数据源,支持json,xml,支持资源内嵌 Value 打在构造方法的Parameter,类的Property,类的Field 静态数据装配 Aspect 打在class上面 开启拦截器,默认注册为类拦截器,可以指定接口型拦截器 【Autofac打标签模式】AutoConfiguration和Bean 【 Autofac打标签模式】开源DI框架扩展地址: https://github.com/yuzd/Autofac.Annotation/wiki /*--> */ /*--> */ 让一个配置类去注册一些单例对象到DI容器内 打了AutoConfiguration标签的Class就是配置类 在AutoConfiguration标签的Class里面打了Bean标签的返回对象就是要注册的单例对象 原理解释: 框架会扫描打了

【Autofac打标签模式】AutoConfiguration和Bean

纵饮孤独 提交于 2019-12-01 12:13:46
【 Autofac打标签模式】开源DI框架扩展地址: https://github.com/yuzd/Autofac.Annotation/wiki /*--> */ /*--> */ 让一个配置类去注册一些单例对象到DI容器内 打了AutoConfiguration标签的Class就是配置类 在AutoConfiguration标签的Class里面打了Bean标签的返回对象就是要注册的单例对象 原理解释: 框架会扫描打了【AutoConfiguration】的class,然后会再扫描打了【Bean】标签的方法并且Invoke该方法,拿到方法返回的对象并以单例的形式注册到DI容器中! AutoConfiguration标签支持下面几个参数配置 Key:如果指定key OrderIndex:值越大越先处理 Key的使用方法请查看下面的实例代码的注释 //这个会加载 [AutoConfiguration("Test")] public class MyConfig { [Bean] public MyModel GetMyModel() { return new MyModel { Name = "yuzd" }; } } //这个不会被加载 [AutoConfiguration("Prod")] public class MyConfig2 { [Bean] public

Why my Subscribe method is not called when using Prism EventAggregator?

落爺英雄遲暮 提交于 2019-12-01 11:57:31
I am learning Prism. Few hours already I am facing a problem, when subscribing to the event, the subscription method is not called. I am using Prism and Autofac . In the simplified example below, in MainViewModel Publish("dupa"); event is called in the ctor . And on button click UpdateWindow is opened. In backend of the window is created instance of UpdateViewModel . Inside of update VM ctor is ran, but after Subscribe(UpdateName); the UpdateName is not executed, because of some reason that I do not understand. Complete code: public class MainViewModel : ViewModelBase { private

Why my Subscribe method is not called when using Prism EventAggregator?

一曲冷凌霜 提交于 2019-12-01 10:25:37
问题 I am learning Prism. Few hours already I am facing a problem, when subscribing to the event, the subscription method is not called. I am using Prism and Autofac . In the simplified example below, in MainViewModel Publish("dupa"); event is called in the ctor . And on button click UpdateWindow is opened. In backend of the window is created instance of UpdateViewModel . Inside of update VM ctor is ran, but after Subscribe(UpdateName); the UpdateName is not executed, because of some reason that I