Error with nopCommerce image with API plug-in

2 settimane tempo fa
Hello,

I built a nopCommerce image with the API plugin by adding the following lines to the build plugins section of the Dockerfile:
WORKDIR /src/Plugins/Nop.Plugin.Misc.WebApi.Frontend
RUN dotnet build Nop.Plugin.Misc.WebApi.Frontend.csproj -c Release
WORKDIR /src/Plugins/Nop.Plugin.Misc.WebApi.Framework
RUN dotnet build Nop.Plugin.Misc.WebApi.Framework.csproj -c Release
WORKDIR /src/Plugins/Nop.Plugin.Misc.WebApi.Backend
RUN dotnet build Nop.Plugin.Misc.WebApi.Backend.csproj -c Release


But, when I try to run the image on my server, I get the following errors:
nopcommerce   | Unhandled exception. System.InvalidOperationException: Failed to convert configuration value at 'DistributedCacheConfig:DistributedCacheType' to type 'Nop.Core.Configuration.DistributedCacheType'.
nopcommerce   |  ---> System.FormatException: redissynchronizedmemory is not a valid value for DistributedCacheType.
nopcommerce   |  ---> System.ArgumentException: Requested value 'redissynchronizedmemory' was not found.
nopcommerce   |    at System.Enum.TryParseByName(RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)
nopcommerce   |    at System.Enum.TryParseInt32Enum(RuntimeType enumType, ReadOnlySpan`1 value, Int32 minInclusive, Int32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, Int32& result)
nopcommerce   |    at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
nopcommerce   |    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
nopcommerce   |    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
nopcommerce   |    --- End of inner exception stack trace ---
nopcommerce   |    at System.ComponentModel.EnumConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
nopcommerce   |    at Microsoft.Extensions.Configuration.ConfigurationBinder.TryConvertValue(Type type, String value, String path, Object& result, Exception& error)
nopcommerce   |    --- End of inner exception stack trace ---
nopcommerce   |    at Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, BindingPoint bindingPoint, IConfiguration config, BinderOptions options)
nopcommerce   |    at Microsoft.Extensions.Configuration.ConfigurationBinder.BindProperty(PropertyInfo property, Object instance, IConfiguration config, BinderOptions options)
nopcommerce   |    at Microsoft.Extensions.Configuration.ConfigurationBinder.BindProperties(Object instance, IConfiguration configuration, BinderOptions options)
nopcommerce   |    at Microsoft.Extensions.Configuration.ConfigurationBinder.BindInstance(Type type, BindingPoint bindingPoint, IConfiguration config, BinderOptions options)
nopcommerce   |    at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationSettings(IServiceCollection services, WebApplicationBuilder builder) in /src/Presentation/Nop.Web.Framework/Infrastructure/Extensions/ServiceCollectionExtensions.cs:line 75
nopcommerce   |    at Program.<Main>$(String[] args) in /src/Presentation/Nop.Web/Program.cs:line 21
nopcommerce exited with code 139


Does anyone have any clue what I'm doing wrong here?
2 settimane tempo fa
Hi. Please specify which version of nopCommerce you are using. It seems the problem is not in the WebAPI plugin but in appsettings.json file. The fact is that the "redissynchronizedmemory" distributed caching type appeared only in 4.70 and cannot be set for earlier versions
1 settimana tempo fa
It was indeed a mismatch between the API version and NopCommerce! It works now. 😊 Thank you.
1 settimana tempo fa
Hello,

The error message you are encountering suggests that there is a configuration issue related to the DistributedCacheConfig:DistributedCacheType setting. Specifically, the value redissynchronizedmemory is not a recognized option for DistributedCacheType. Here's a detailed analysis and steps to troubleshoot and resolve the issue.
The DistributedCacheType enum likely has specific valid values. Common valid values for caching configurations could include options like Memory, Redis, DistributedSqlServerCache, etc. The error indicates that redissynchronizedmemory is not a valid enum value.
Inspect your configuration files (e.g., appsettings.json, appsettings.Production.json, or environment-specific configuration files) for the DistributedCacheConfig section and ensure that the DistributedCacheType is set to a valid value.
Based on the valid values for DistributedCacheType, update the configuration to use one of the valid options. If you are unsure of the valid values, you can refer to the nopCommerce documentation or source code where the DistributedCacheType enum is defined.
If your configuration is coming from environment variables or other sources that are set in your Dockerfile or Docker Compose file, ensure they are set correctly.
After updating the configuration, rebuild your Docker image and redeploy it to apply the changes.

If you need to verify or understand what values are acceptable for DistributedCacheType, you can look into the nopCommerce source code where the enum is defined.

Best Regards, Maxim Time Clock