Hi, actually, you should have a shared library for your localization files and the related configuration. So, for example, if you move your localization configurations and the related Localization/Resources/Test/*.json
to *.Application.Contracts
it should work.
In summary, you should have a shared library to make these configurations (because normally, Blazor.Client is a Blazor WASM application at its core), and then you can inject the IStringLocalizer<TestResource>
and use it in your blazor application:
1-)
2-) Update the related *.csproj
:
<ItemGroup>
<EmbeddedResource Include="Localization\Resources\Test\*.json" />
<Content Remove="Localization\Resources\Test\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="9.0.0" />
</ItemGroup>
<PropertyGroup>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
3-) Then, use it in your page:
But when I send this dto to create method of service, I get an error of this type: System.InvalidOperationException, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
Hi Murat, API is using the default .NET model binder, and something in your custom attribute is causing a validation metadata exception or reflection issue before the controller is even entered.
There are some checks that you can do:
PspResource
is in a shared project. (It typically should be in *.Domain.Shared
project)[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter,
AllowMultiple = false)]
public class PspRequiredAttribute : RequiredAttribute
{
public PspRequiredAttribute()
{
//ErrorMessageResourceName = nameof(PspResource.RequiredAttribute_ValidationError);
//ErrorMessageResourceType = typeof(PspResource);
}
}
When your API (the backend part) tries to reflect over the DTO, it's trying to fetch the error message string via the
ErrorMessageResourceType
during model binding, and probably this where you get error.
After you have tried these two suggestions, please let me know about the situation. If it's not related to reflection problem, then please share your PspResource
class and give more details (such as where the resource class is defined, where you created the attribute, and any other context)
Regards.
Hi, thanks for the detailed explanation!
I've followed your suggestion and updated the
OnChange
handler to use anasync
lambda as shown:However, I'm still seeing the default error dialog (from ABP) even though the exception is caught and I’m manually showing a toast notification.
And can i ask are there any supported way to disable this dialog globally or override the error handling mechanism or correctly to handle this?
Thanks again for your support!
<TelerikSwitch Value="@item.IsActive" OnLabel=" " OffLabel=" " Size="@ThemeConstants.Switch.Size.Small" OnChange="@(async () => await ToggleStatus(item))" /> private async Task ToggleStatus(ContainerTypeDto item) { try { var messageKey = item.IsActive ? "Delete:ConfirmInactiveMessage" : "Delete:ConfirmActiveMessage"; var message = L[messageKey, L["ContainerType"]]; if (await Dialogs.ConfirmAsync(message, L["Dialog:ConfirmAction"])) { LoaderVisible = true; SelectedContainerTypeId = item.Id.ToString(); await ContainerTypeService.ChangeStatusAsync(Guid.Parse(SelectedContainerTypeId)); var result = await ContainerTypeService.GetListAsync(new ContainerTypeRequestDto()); ContainerTypes = result.Items.ToList(); await Notify.Success(L["Messages:Success"]); } } catch (Exception e) { Logger.LogError(e, "Error changing container type status for ID: {SelectedContainerTypeId}", SelectedContainerTypeId); await Notify.Error(string.IsNullOrEmpty(e.Message) ? L["Messages:Error"] : e.Message); } finally { LoaderVisible = false; } } public async Task ChangeStatusAsync(Guid containerTypeId) { var containerType = await repository.GetAsync(containerTypeId); var hasInUse = await containerRepository .AnyAsync(d => d.ContainerTypeId == containerTypeId && !d.IsDeleted && d.Asset != null && d.Asset.IsActive); if (hasInUse) { throw new BusinessException(TmsSolutionDomainErrorCodes.ContainerTypeIsInUse); } containerType.IsActive = !containerType.IsActive; await repository.UpdateAsync(containerType); }
Hi, you should catch UserFriendlyException
, because ABP shows dialog for this exception type. Can you try like in my suggested code?
Is the next patch release date obvious?
We haven't decided on the date, but it will probably be next week.
Hi,
It works now. Thank you.
There are some enconding characters (%20) at the end of the latest-version.json file url.
Is it possible that the latest version information cannot be obtained because of this when performing an ABP update?
Yes, it might be. I'll check that, thanks for pointing that out 👍
Hi, when using the abp update
command, normally, the command checks the latest stable version from this file and then updates your project.
So, it's really weird to see that. Can you try to update by specifying the version and see if it works for you:
abp update --version 9.1.1
Hi, it's impossible for us to fix the problem with the shared logs. Actually, we are directly using Hangfire's own dashboard UI and you can check their documentation to understand the reason: https://docs.hangfire.io/en/latest/configuration/using-dashboard.html
Please refer to the related documentation, and if you still can't fix your problem, then we can assist you.
Thanks for sharing the test via email. We got your mail and we will evaluate it.
I’m unable to generate static proxies. I recommend that you replicate my setup and create the solution the same way I did to identify any potential issues.
I tried with your exact setup and still able to generate proxies:
1-)
2-)
3-) Created a dummy appservice -> ProductAppService.cs in the related service and ran the services:
4-) Generated proxies successfully:
Please read each step carefully and see if you missed any points or not. Because I'm unable to reproduce the problem you stated with the limited information. (you first said that you are using Blazor web app
and then said using Blazor Server
and, i've tried with both and finally used the last approach)
So, it can be good to share your solution via email (to support@abp.io with the ticket number), so I can directly check your solution.
As you can see from the previous answers, I have tried with the exact setup of yours and unable to reproduce it so there might be some steps that you forget to mention etc.
So, let's continue from your own microservice solution. Let me know after you send your ms solution.
Regards.