Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error resolving IHubContext<,> in ASP.NET Core #50

Closed
cd21h opened this issue Aug 3, 2019 · 2 comments
Closed

Error resolving IHubContext<,> in ASP.NET Core #50

cd21h opened this issue Aug 3, 2019 · 2 comments
Assignees

Comments

@cd21h
Copy link

cd21h commented Aug 3, 2019

Not 100% sure if should go to Autofac.Core or here.

Getting this exception when resolving SiglanR IHubContext<Hub,IClient>, resolving IHubContext<Hub> works fine.

If .ConfigureServices(services => services.AddAutofac()) is commented out, both services can be resolved. Everything works fine if I use MS dependency Injection.

  • ASP,NET Core 2.1
  • Autofac 4.9.3
  • Autofac.Extensions.DependencyInjection 4.4.0

Steps to reproduce

Download and run attached example.

Exception

System.InvalidOperationException
  HResult=0x80131509
  Message=This operation is only valid on generic types.
  Source=System.Private.CoreLib
  StackTrace:
   at System.RuntimeType.GetGenericTypeDefinition()
   at Autofac.Util.TypeExtensions.ParameterCompatibleWithTypeConstraint(Type parameter, Type constraint)
   at Autofac.Util.TypeExtensions.<>c__DisplayClass7_1.<IsCompatibleWithGenericParameterConstraints>b__1(Type constraint)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Autofac.Util.TypeExtensions.IsCompatibleWithGenericParameterConstraints(Type genericTypeDefinition, Type[] parameters)
   at Autofac.Features.OpenGenerics.OpenGenericServiceBinder.TryBindServiceType(Service service, IEnumerable`1 configuredOpenGenericServices, Type openGenericImplementationType, Type& constructedImplementationType, Service[]& constructedServices)
   at Autofac.Features.OpenGenerics.OpenGenericRegistrationSource.<RegistrationsFor>d__3.MoveNext()
   at Autofac.Core.Registration.ComponentRegistry.GetInitializedServiceInfo(Service service)
   at Autofac.Core.Registration.ComponentRegistry.TryGetRegistration(Service service, IComponentRegistration& registration)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable`1 parameters)
   at SignalRTest1.Startup.ConfigureServices(IServiceCollection services) in D:\Temp\AutofacIssue\Startup.cs:line 41

AutofacIssue.zip

@alsami alsami self-assigned this Aug 3, 2019
@alsami
Copy link
Member

alsami commented Aug 3, 2019

Hi @Shatl,

this bug has already been fixed by @alistairjevans in the Autofac repository . Only version 4.9.3 is affected from that. Until we have released a new version of Autofac downgrading to 4.9.2 fixes the issue.

@alsami alsami closed this as completed Aug 3, 2019
@cd21h
Copy link
Author

cd21h commented Aug 6, 2019

Thanks @alsami

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants