I need your help for a problem in PRODUCTION environment!
I'm building an .NET 6 Blazor WASM-Hosted application, which works fine in localhost.
However, in production environment, after publishing the solution, when I try to get some users, I encounter the below exception:
A member with the name '' already exists on 'System.Tuple`2[System.Collections.Generic.List`1[einvoices.Shared.Models.UserEntity],System.Collections.Generic.List`1[einvoices.Shared.Models.UserRoleEntity]]'. Use the JsonPropertyAttribute to specify another name.
This is a front-end exception, coming from the Newtonsoft nuget package.
I have a GetUsers() method in my Services in the front-end, which I call:
public async Task<Tuple<List<UserEntity>,List<UserRoleEntity>>> GetUsers()
{
return await _httpService.Get<Tuple<List<UserEntity>, List<UserRoleEntity>>>($"{url}/GetUsers");
}
I also have in the front-end a HttpService to organize all my GET-POST-PUT-DELETE calls:
public async Task<T> Get<T>(string url)
{
var request = new HttpRequestMessage(HttpMethod.Get, url);
_loadingService.Show();
HttpResponseMessage httpResponseMessage = await _httpClient.SendAsync(request);
_loadingService.Hide();
string responseString = await httpResponseMessage.Content.ReadAsStringAsync();
if (httpResponseMessage.IsSuccessStatusCode)
{
T? responseDeserialized = JsonConvert.DeserializeObject<T>(responseString);
return responseDeserialized;
}
else
{
throw new Exception(responseString);
}
}
Now, if I use the System.Text.Json package instead of Newtonsoft, I get the below exception:
ConstructorParamIncompleteBinding, System.Tuple
2[System.Collections.Generic.List1[HAFeInvoices.Shared.Models.UserEntity],System.Collections.Generic.List`1[HAFeInvoices.Shared.Models.UserRoleEntity]]
I have ASP.NET Core Runtime 6.0.27 Hosting Bundle installed in the server. All my application packages have been updated to 6.0.27 version.
It is worth-mentioning that the error says
A member with the name '' already exists ...
and the name is empty. Usually a specific member name had to appear.
As you can see, I am using Tuples, if this means anything.
Do you have any idea what is going on?
I appreciate your help!