5

I have got a class extending DomainService abstract class as below:

public class ScheduleManager : DomainService, IScheduleManager

The following line does not work:

throw new UserFriendlyException(L("ScheduleIsNotValid"));

because of: Abp.AbpException: Must set LocalizationSourceName before, in order to get LocalizationSource

Just wonder where the proper place if for setting the LocalizationSourceName, like it was set in MyCarParkControllerBase, but in Core (Domain) layer?

By the way the there are 2 usages of localization in the UserRegistrationManager class as:

Line 96 >>> throw new UserFriendlyException(L("UnknownTenantId{0}", tenantId));
Line  101 >>> throw new UserFriendlyException(L("TenantIdIsNotActive{0}", tenantId));

That are failing due to the same issue!

Cheers,

George Wurthmann
  • 411
  • 2
  • 8
  • 20
Mohammad Shadmehr
  • 675
  • 11
  • 26

2 Answers2

3

In Core project, create an abstract base class for DomainService. Set localization source in constructor. That's it!

enter image description here

Alper Ebicoglu
  • 8,884
  • 1
  • 49
  • 55
0

Just to be more clear:

AbpServiceBase implement the propertie LocalizationSourceName:

protected string LocalizationSourceName { get; set; }

And in Core Module you can find in PreInitialize the localization configurer:

MyProjectLocalizationConfigurer.Configure(Configuration.Localization);

In the Configure method you can see the name of the Localization, this name need to be used in the constructor like @Alber Ebicoglu already showed.

Like this:

public AbpLoginResultTypeHelper(IAccountAppService accountAppService)
{
    LocalizationSourceName = MyProjectConsts.LocalizationSourceName; //Localization name
    _accountAppService = accountAppService;
}
George Wurthmann
  • 411
  • 2
  • 8
  • 20