-
Notifications
You must be signed in to change notification settings - Fork 144
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 in BusClientFactory.CreateDefault() on net core 2.0 #257
Comments
Hi, @Kilovatiy - thanks for reporting this. I haven't had time to look into the changes of .NET Core 2.0, but apparently some contracts have changed. I'm focusing on v 2.0 of RawRabbit ATM, but feel free to submit a PR for this! |
Not sure what the underlying problem is. Based on this dotnet/efcore#8498 (comment) it sounds like the problem can be resolved by removing the bin folder. I looked into the possibility to upgrade |
I think this has something to do with the netcoreapp assembly bindings. Strangely enough this exception is not being thrown in a .net core console application but only in a .net core web application for whatever reason. So I took a look in the BusClientFactory class and tried to construct the objects the same way in my code. Long story short everything works now as expected. It might be a bit cumbersome but frankly speaking I don't care as the bus client object can be stored in a IoC container as well. So my code looks like this now:
and similarly while using the AdvancedMessageContext:
BTW, don't forget to reference Microsoft.Extensions.DependencyInjection 2.0 as I was still getting an error without it. |
I have the same problem. RawRabbit in .NET Core 2.0 console application was fine, .NET Core 2.0 web hosted application is not working, with above error. @samirski I don't understand your solution. You are adding RawRabbit to DI service provider, but then you are instantiating the bus client without using the service provider..? Why not just skip adding it to the service collection? |
It looks like an upgrade to .NET Standard 2.0 is the only option. @pardahlman If I submitted a PR for an upgrade to 2.0 would you be ok with that or looking to keep compatibility with lower version? Will RawRabbit v2 target .NET Standard 2.0? |
Can work around this by resolving RawRabbit.IBusClient instead of RawRabbit.vNext.Disposable.IBusClient |
@MrGlenThomas I'm hesitant to target .NET Standard 2.0, as it will break compatibility with users that target a framework compatible with a lower standard (for example .NET Framework 4.6). The idea with .NET Standard is that a higher version is a super-set of all previous versions. This also makes sense according to this article on .NET Standard
|
My gut feeling is that something has changed in |
It does appear that a change to the DI is the cause and the only way around it (without .NET Standard 2.0) would be to add a new method of building the BusClient object graph that doesn't use the .NET DI library. Maybe could allow people to use alternative containers like structuremap/autofac/ etc. |
Facing the same issue here as I have just upgraded the majority of my projects to 2.0 Would it be possible to release a separate version, or even a separate package, that specifically targets .NET Standard 2.0? *Note: As a workaround, I've added the following lines in place of BusFactory.CreateDefault:
As long as the assembly running these lines is using .NET Standard 2.0, you will not hit a runtime exception as the IServiceCollection.BuildServiceProvider() method is not run. |
So this comment sums it up
Unfortunately, Not sure how to resolve this issue. The work-around (above) seems like a acceptable workaround for now. |
How about having multiple target frameworks in the csproj? |
Hi @Manny651 - thanks for the input. RawRabbit already has multiple targets, which is part of the problem. Can you elaborate on what you mean? |
@jwoodman510 How to set Rawrabbit configuration with this approach? |
Hi,
I use RawRabbit.vNext version 1.10.3.
I update my app from core 1.2 to core 2.0 and start receiving an error -
Method not found:
'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
Here is stack trace:
at RawRabbit.vNext.BusClientFactory.CreateDefault(IServiceCollection services) at IBE.Amadeus.SessionPool.MessageQueueClientFactory.GetSingletonInstance(RawRabbitConfiguration config) in C:\Work_proj\ibe-backend\IBE.Amadeus.SessionPool\MessageQueueClientFactory.cs:line 27 at IBE.Amadeus.SessionPool.ServiceCollectionExtensions.<>c__DisplayClass0_0.<AddSessionPool>b__0(IServiceProvider ioc) in C:\Work_proj\ibe-backend\IBE.Amadeus.SessionPool\ServiceCollectionExtensions.cs:line 34 at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument)at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor
2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.Internal.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired) at lambda_method(Closure , IServiceProvider , Object[] ) at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
Thanks
The text was updated successfully, but these errors were encountered: