abp new Acme.BookStore -u blazor --preview````
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.get_IsCompleted()
at Microsoft.AspNetCore.RequestLocalization.DefaultAbpRequestLocalizationOptionsProvider.GetLocalizationOptionsAsync()
at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
````
Same for an MVC project too.
I get an error when I use Rider run Api.Host, but everything is working when I debug Api.Host.
Problem code line is:
Temporary patch: Copy MyDefaultAbpRequestLocalizationOptionsProvider to your project
[Dependency(ReplaceServices = true)]
public class MyDefaultAbpRequestLocalizationOptionsProvider : IAbpRequestLocalizationOptionsProvider, ISingletonDependency
{
private readonly IServiceScopeFactory _serviceProviderFactory;
private readonly SemaphoreSlim _syncSemaphore;
private Action<RequestLocalizationOptions> _optionsAction;
private RequestLocalizationOptions _requestLocalizationOptions;
public MyDefaultAbpRequestLocalizationOptionsProvider(IServiceScopeFactory serviceProviderFactory)
{
_serviceProviderFactory = serviceProviderFactory;
_syncSemaphore = new SemaphoreSlim(1, 1);
}
public void InitLocalizationOptions(Action<RequestLocalizationOptions> optionsAction = null)
{
_optionsAction = optionsAction;
}
public RequestLocalizationOptions GetLocalizationOptions()
{
if (_requestLocalizationOptions != null)
{
return _requestLocalizationOptions;
}
return AsyncHelper.RunSync(GetLocalizationOptionsAsync);
}
public async Task<RequestLocalizationOptions> GetLocalizationOptionsAsync()
{
if (_requestLocalizationOptions == null)
{
using (await _syncSemaphore.LockAsync())
{
if (_requestLocalizationOptions == null)
{
using (var serviceScope = _serviceProviderFactory.CreateScope())
{
var languageProvider = serviceScope.ServiceProvider.GetRequiredService<ILanguageProvider>();
var settingProvider = serviceScope.ServiceProvider.GetRequiredService<ISettingProvider>();
var languages = await languageProvider.GetLanguagesAsync();
var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
var options = !languages.Any()
? new RequestLocalizationOptions()
: new RequestLocalizationOptions
{
DefaultRequestCulture = DefaultGetRequestCulture(defaultLanguage, languages),
SupportedCultures = languages
.Select(l => l.CultureName)
.Distinct()
.Select(c => new CultureInfo(c))
.ToArray(),
SupportedUICultures = languages
.Select(l => l.UiCultureName)
.Distinct()
.Select(c => new CultureInfo(c))
.ToArray()
};
_optionsAction?.Invoke(options);
_requestLocalizationOptions = options;
}
}
}
}
return _requestLocalizationOptions;
}
private static RequestCulture DefaultGetRequestCulture(string defaultLanguage, IReadOnlyList<LanguageInfo> languages)
{
if (defaultLanguage == null)
{
var firstLanguage = languages.First();
return new RequestCulture(firstLanguage.CultureName, firstLanguage.UiCultureName);
}
var (cultureName, uiCultureName) = LocalizationSettingHelper.ParseLanguageSetting(defaultLanguage);
return new RequestCulture(cultureName, uiCultureName);
}
}
+1 - except I cannot get past the above mentioned error. i'm using:
Abp new [myproj] --ui blazor --preview
when you say "update the CLI" - what version of the CLI is the latest/best to use with 4.0.0-rc.1?
I tried to update the CLI with:
dotnet tool update -g Volo.Abp.Cli
which gives me
Tool 'volo.abp.cli' was reinstalled with the latest stable version (version '3.3.1').
@274188A
dotnet tool uninstall --global Volo.Abp.Cli
dotnet tool install --global Volo.Abp.Cli --version 4.0.0-rc.1
@274188A https://github.com/abpframework/abp/issues/6180#issuecomment-726442950
I will investigate this.
Temporary patch: Copy MyDefaultAbpRequestLocalizationOptionsProvider to your project
Could you be more specific with the description "your project" - ie which project?
thanks (i'm assuming you mean the host but assumptions can be dangerous :-)
Could you be more specific with the description "your project" - ie which project?
XXX.HttpApi.Host
We need to republish all packages to resolve.
ok wait the stable version
Most helpful comment
@274188A https://github.com/abpframework/abp/issues/6180#issuecomment-726442950
I will investigate this.