Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider' - c#

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?

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.

Related

Azure Pipelines unable to find .Net framework version 4.0

My solution uses the latest version of .net which is 4.8. However, I see the following error message that complaints about a version 4.0 in Azure Pipelines. Can someone let me know how I could resolve this please ?
The error message indicates I need to install 4.0 but I don't think that's the solution. I also opened up the file Microsoft.Common.CurrentVersion.targets and line 1221 has the following. However, I know it is not advisable to edit this file.
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
The error message:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1221,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Note: There are many similar post in SO that suggest to install VS2019. However, I am getting this message while running the application on Azure Pipelines.
Update
From your description, you are using the Microsoft host agent and the pipeline pop out issue 'cannot found NETFramework,Version=v4.0'.
Your environment looks like this:
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#net-framework
or
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md#net-framework
You can see that the Microsoft host agent does not have the environment you mentioned.
Although you can install what you need at the beginning of the pipeline startup, I do not recommend this practice. Because when you choose microsoft host agent, every time you start the pipeline, you will be assigned a brand new azure VM machine, which means you need to install the relevant environment every time.
The recommended approach is to use a self-host agent. Please create a self-host agent based on your local machine (or another machine with the relevant environment), the steps are as follows:
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
Provided above are the installation steps of windows self host agent, the steps should be very simple, if you encounter any problems please let me know.
And after that, you can run your pipeline based on that self host agent like this:
pool:
name: <your agent pool name>
If you are using classic pipeline, just click and select:
(If you run successfully on local, then the agent based on local machine should also be no problem.)
And if this is still unable to solve your issue, could you please remove the in-private information and share the YAML file or JSON file, and let me know at which step you encountered this issue?

Which Namespace or Nuget Binding BlobProperties in Azure Functions V3

Is there a Nuget/Assembly/Library that will allow me to bind BlobProperties for .NET Core Azure 3.x Functions, in both a local environment and in an Azure environment?
I have an Azure Function running on .NET Core 3 with a signature that looks like this:
public async Task DoFunctionWork([BlobTrigger("path/to/{blobName}")] Stream blobStream,
**Microsoft.Azure.Storage.Blob.BlobProperties Properties**)
{
//Function Body....
}
The problem is with the Properties parameter. If run locally, it can only be resolved if I prefix the BlobProperties parameter with the Microsoft.Azure.Storage.Blob namespace as above. In Azure, it never seems to work. When it fails - on either Azure or locally - I get one of the following messages:
Can't bind properties to type 'Azure.Storage.Blob.Properties' or Can't bind properties to type 'Microsoft.Azure.Storage.Blob.Properties'
Has anyone encountered this before? How did you solve it?
Thanks.
It looks like this is because, there is a version mismatch between what your SDK requires and what you have installed.
For instance, if you are using 3.0.9 version of Function SDK, then you might have installed Microsoft.Azure.WebJobs other than (>= 3.0.0 && < 3.1.0) versions.
Microsoft.NET.Sdk.Functions 3.0.9
Microsoft.Azure.WebJobs.Extensions.Storage 4.0.3

Tests for Azure Table Storage using Microsoft.Azure.Storage.Common 9.4.0.2-preview

I created a .NET Standard 2.0 class library where I use Azure table storage as it's described here - https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet. Also, I created a .NET Core test project to test my client library. And when I run a simple test I get this:
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.Azure.Documents.Client, Version=1.22.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
I tried many things to make it work but this is just waste of time. How do I fix this?
Microsoft.Azure.Documents.Client package is now obselete. Please use Microsoft.Azure.DocumentDB package instead.
Refer here
Nuget Console:
Install-Package Microsoft.Azure.DocumentDB.Core -Version 1.9.1
(Or)
Install-Package Microsoft.Azure.DocumentDB -Version 2.0.0-preview2
See more about this System.IO.FileNotFoundException : Could not load file or assembly error

Error:An unknown error occurred while invoking the service metadata component. Failed to generate service reference

When trying to use .net core 2.1 rc1 to add a service reference for WCF, I am experiencing the following error:
Error:An unknown error occurred while invoking the service metadata component. Failed to generate service reference
I have checked and the only security in place is Transport, no message security.
The logs are as follows:
[05/24/2018 12:28:28],59,Importing web service metadata ...
[05/24/2018 12:28:28],27,Number of service endpoints found: 2
[05/24/2018 12:28:28],9,Scaffolding service reference code ...
[05/24/2018 12:28:28],71,Executing command [C:\Users\me\AppData\Local\Temp\WCFConnectedService\2018_May_24_12_28_28\svcutil_starter]
"dotnet new console --no-restore --force --type project --language C# --output . --name svcutil_starter"
[05/24/2018 12:28:30],9,Executing command [C:\Users\me\AppData\Local\Temp\WCFConnectedService\2018_May_24_12_28_28\svcutil_starter]
"dotnet restore --ignore-failed-sources"
[05/24/2018 12:28:31],35,Executing command [C:\Users\me\AppData\Local\Temp\WCFConnectedService\2018_May_24_12_28_28\svcutil_starter]
"dotnet "svcutil" --additionalprobingpath "C:\Users\me\\.nuget\packages" "C:\Users\me\AppData\Local\Temp\WCFConnectedService\2018_May_24_12_28_28\SvcUtilParams.txt""
[05/24/2018 12:28:32],52,An unknown error occurred while invoking the service metadata component.
Failed to generate service reference.
[05/24/2018 12:28:32],11,Done.
As a temporary solution to this issue I have added a new Project to my solution, set it to Asp Core 1.1 and added the connected service that way which appears to work.
It would seem 2.1 is broken currently and I'll have to wait for updates before doing it directly in my Project.
Edit: Thanks to User3130628. This has now been fixed and appears to be working, even in VS 15.7.5.
I suspect the Core framework has been updated and this has corrected the issue.
Till 2018-07-31, it still has problems for NET Core 2.1.x to add a service reference for WCF in VS2017 (v15.7.5). You can create Net 2.0.x project to create the connected service, it'll work perfect. Then copy the 'Connected Services' sub-directory in project to new NET core v2.1.x project.
Installs the following packages via NuGet such as this image:
NuGet Packages for Connected Services
Compiled successfully in NET Core 2.1.x project.
As of today VS2017 15.8.1 it seems to be working again with .Net core 2.1.401
Not sure why this worked for me:
Created second Temp new project targeted to .Net Core 2.0 (in another instance of VS)
Make service reference call (Microsoft WCF Web Service Reference Provider) with .wsdl uri
Open 1st project (target project targetted to .Net Core 2.1) and add the service reference the same way.
Not sure why this worked. Without creating the second solution in a different instance of Visual Studio, it was not working.
Hope this helps.

Xamarin.Firebase.Common not compatible with Xamarin.Firebase.Auth

I'm trying to install 'Xamarin.Firebase.Storage.42.1021.1' so I can upload photos to my firebase database
I'm targeting 'MonoAndroid, Version=v7.1'
However, when I try to install the package I get the following
Unable to find a version of 'Xamarin.Firebase.Common' that is compatible with 'Xamarin.Firebase.Auth 42.1024.0-beta1 constraint: Xamarin.Firebase.Common (= 42.1024.0-beta1)', 'Xamarin.Firebase.Storage 42.1021.1 constraint: Xamarin.Firebase.Common (= 42.1021.1)'.
Is there a quick fix without breaking my project?
You may checked the Dependencies of Xamarin.Firebase.Storage and Xamarin.Firebase.Auth.
According to your error message, you've installed the Xamarin.Firebase.Auth 42.1024.0-beta1 package, which needs dependency Xamarin.Firebase.Common (= 42.1024.0-beta1).
Try to downgrade your Xamarin.Firebase.Auth package to version 42.1021.1.

Categories

Resources