I am updating the code from Autofac 1.4 to 2.1.10 Release Candidate.
My module previously did the registration as follows:
builder.RegisterCollection<IExceptionHandler>() .As<IEnumerable<IExceptionHandler>>() .FactoryScoped(); builder.Register<AspNetExceptionHandler>() .As<IExceptionHandler>() .MemberOf<IEnumerable<IExceptionHandler>>() .FactoryScoped();
Now RegisterCollection has no overload parameters. I do not need to give him a name. Assuming this is fine, just type null , my code looks like this: 2.1:
builder.RegisterCollection<IExceptionHandler>(null) .As<IEnumerable<IExceptionHandler>>() .InstancePerDependency(); builder.RegisterType<AspNetExceptionHandler>() .As<IExceptionHandler>() .MemberOf<IEnumerable<IExceptionHandler>>(null) .InstancePerDependency();
However, when compiling, I get the following error regarding .MemberOf :
Using the common method 'Autofac.RegistrationExtensions.MemberOf (Autofac.Builder.RegistrationBuilder, string)' requires arguments of type 3 '
I tried to insert the name of the collection instead of null, just in case, and this did not affect.
What is the correct way to register collections in 2.1?
autofac
Hackedbychinese
source share