Open Alienroid opened 4 years ago
Can you please describe the workaround more thoroughly? You mention to 'just use the new library from Microsoft"... which library are you talking about?
According to blazor wasm preview 3 release note:
extension methods are now available in preview with the System.Net.Http.Json package and they will replace the existing helper methods in the Microsoft.AspNetCore.Blazor.HttpClient package
The old one will have conflict. The new ones have different name. Old ones:Microsoft.AspNetCore.Blazor.HttpClient GetJsonAsync
New lib System.Net.Http.Json GetFromJsonAsync
Still though... Not sure why matBlazor needs to define own GetJsonAsync
Currently this bug breaks all .net5 builds.
DepartmantShow.razor(40, 37): [CS0121] The call is ambiguous between the following methods or properties: 'Microsoft.AspNetCore.Components.HttpClientJsonExtensions.GetJsonAsync<T>(System.Net.Http.HttpClient, string)' and 'MatBlazor.MatHttpClientExtension.GetJsonAsync<T>(System.Net.Http.HttpClient, string)'
Can you please remove this if not needed or rename it to not conflict with the blazor framework?
Currently this bug breaks all .net5 builds.
DepartmantShow.razor(40, 37): [CS0121] The call is ambiguous between the following methods or properties: 'Microsoft.AspNetCore.Components.HttpClientJsonExtensions.GetJsonAsync<T>(System.Net.Http.HttpClient, string)' and 'MatBlazor.MatHttpClientExtension.GetJsonAsync<T>(System.Net.Http.HttpClient, string)'
Can you please remove this if not needed or rename it to not conflict with the blazor framework?
i agree with you
Can you please describe the workaround more thoroughly? You mention to 'just use the new library from Microsoft"... which library are you talking about?
my workaround : downgate matblazor to 2.4.3
'Microsoft.AspNetCore.Components.HttpClientJsonExtensions.GetJsonAsync’ is the msft lib
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: seebosmilemailto:notifications@github.com Sent: Friday, August 7, 2020 4:21 PM To: SamProf/MatBlazormailto:MatBlazor@noreply.github.com Cc: Alienroidmailto:iam31337@hotmail.com; Authormailto:author@noreply.github.com Subject: Re: [SamProf/MatBlazor] MatHttpClientExtension has conflict with Microsoft.AspNetCore.Components.HttpClientJsonExtensions (#595)
Currently this bug breaks all .net5 builds.
DepartmantShow.razor(40, 37): [CS0121] The call is ambiguous between the following methods or properties: 'Microsoft.AspNetCore.Components.HttpClientJsonExtensions.GetJsonAsync
Can you please remove this if not needed or rename it to not conflict with the blazor framework?
i agree with you
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SamProf/MatBlazor/issues/595#issuecomment-670781171, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AH3FBMUQFFVEASQYXZWISATR7SD6FANCNFSM4NS6THLQ.
I have a workaround for this "The call is ambiguous" problem:
First, I have created a new static class, named HttpClientHelper, adding the following code:
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;
namespace MyProject.WebGui
{
public static class HttpClientHelper
{
public static Task<T> GetJSONAsync<T>(this System.Net.Http.HttpClient client, string url)
{
return client.GetJsonAsync<T>(requestUri: url);
}
}
}
Then I iterated through the project's Error List to find the GetJsonAsync references and replaced them with GetJSONAsync. For example:
firma = await HttpClient.GetJSONAsync<Firma>(url.ToString());
Now I'm able to use 2.7.0. Cheers
I came across this issue when upgrading my project to .NET 5. This can be fixed by just removing Microsoft.AspNetCore.Blazor.HttpClient and replace affected methods such as SendJsonAsync with PostAsJsonAsync. They're not that different and it's not a lot of work.
That's all I need to do to resolve this.
Describe the bug Extension collision with Microsoft library: Microsoft.AspNetCore.Blazor.HttpClient.GetJsonAsync When calling GetJsonAsync, will cause build error ambiguous with Microsoft.AspNetCore.Components.HttpClientJsonExtensions
One workaround is just use the new library from Microsoft...
To Reproduce Steps to reproduce the behavior:
Blazorfiddle link Please provide a mock implementation of your code on www.blazorfiddle.com - this makes it a lot easier for us and you can get faster feedback on your issue 😉 Hit save and post the URL under this header.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots or .GIF captures to help explain your problem
Additional context Add any other context about the problem here.