You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.ArgumentException with message Type must not be ByRef (Parameter 'type') is thrown when building container if
type constructor contains in parameter.
Looks like this is limitation of lambda. In that case, detailed error message with reference to type being processed (Service in this case) should be thrown.
Exception with Stack Trace
System.ArgumentException
Type must not be ByRef (Parameter 'type')
at System.Dynamic.Utils.TypeUtils.ValidateType(Type type, String paramName, Boolean allowByRef, Boolean allowPointer)
at System.Linq.Expressions.Expression.Convert(Expression expression, Type type, MethodInfo method)
at Autofac.Core.Activators.Reflection.ConstructorBinder.GetConstructorInvoker(ConstructorInfo constructorInfo)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Autofac.Core.Activators.Reflection.ConstructorBinder..ctor(ConstructorInfo constructorInfo)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
at Autofac.Core.Registration.ComponentRegistration.BuildResolvePipeline(IComponentRegistryServices registryServices, IResolvePipelineBuilder pipelineBuilder)
at Autofac.Core.Registration.ComponentRegistration.BuildResolvePipeline(IComponentRegistryServices registryServices)
at Autofac.Core.Registration.ComponentRegistryBuilder.Build()
at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
at AutofacInParameter.UnitTest1.CanBuildContainer()
Dependency Versions
Autofac: 6.0.0
Target Framework: netcoreapp3.1
Additional Info
In the real application that class was registered by mistake using assembly scanning, so it was never resolved, but it took me a while to find root cause, because exception thrown had no reference registration,
The text was updated successfully, but these errors were encountered:
Describe the Bug
System.ArgumentException
with messageType must not be ByRef (Parameter 'type')
is thrown when building container iftype constructor contains
in
parameter.Same code did not throw any exception.
Steps to Reproduce
Expected Behavior
Looks like this is limitation of lambda. In that case, detailed error message with reference to type being processed (
Service
in this case) should be thrown.Exception with Stack Trace
Dependency Versions
Autofac: 6.0.0
Target Framework: netcoreapp3.1
Additional Info
In the real application that class was registered by mistake using assembly scanning, so it was never resolved, but it took me a while to find root cause, because exception thrown had no reference registration,
The text was updated successfully, but these errors were encountered: