0

I have developed a simple console application in .NET6 with target Platform x86 which contains 1 project only with the following packages:

  • Microsoft.AspNetCore.SignalR.Client (6.0.5)

    Microsoft.AspNetCore.SignalR.Common(6.0.5)

    Microsoft.AspNetCore.SignalR.Core(1.1.0)

    System.IO.Ports (6.0.0)

Also it contains an API to communicate with a Dispenser.

This console application send and recieve data with main software throught SignalR and send and recieve data with Dispenser throught API.

I don't use any dependency injection and the Dispenser response when I try to initialize it is the next one:

Método no encontrado: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

Any idea why the response is that?

5
  • Looks like it is missing a library. Try to install Microsoft.Extensions.DependencyInjection.ServiceProvider in the project from nuget. Commented Jun 10, 2022 at 6:58
  • I just installed and the error persits. Commented Jun 10, 2022 at 7:04
  • @JesusHedo Try to turn off compiler optimizations, open project properties, then go to "Build - General". There are options to enable/disable compiler optimizations under title "Optimize code". Commented Jun 10, 2022 at 7:14
  • Please share the code using signalr especially the line throwing the exception. Commented Jun 10, 2022 at 7:20
  • @JHBonarius I would guess that connecting to server would not require all of ASP.NET Core as a dependency. Commented Jun 10, 2022 at 7:22

1 Answer 1

1

Microsoft.AspNetCore.SignalR.Core seems to be a legacy package (last updated in 2018) and was build against Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.2.0), while Microsoft.AspNetCore.SignalR.Client is transitively using Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0) so the later version should be resolved during build. And it definitely has some breaking changes (like removal or signature changes of ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection) method)

Try removing Microsoft.AspNetCore.SignalR.Core package, Microsoft.AspNetCore.SignalR.Client should be sufficient enough to connect to the SingnalR server.

Sign up to request clarification or add additional context in comments.

5 Comments

@JHBonarius the problem clearly comes from Microsoft.AspNetCore.SignalR.Core which seems to be a legacy package which should not be used. Also you can create clients without DI.
Aha, I learned something today. I think that link is the answer. Follow that guide (and don't install other random packages)
But my console application is a server too, also manage requests
@JesusHedo AFAIK you need web application to host SignalR.
@JesusHedo also see this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.