Bug in nop 4.60 beta (two external different DLL files)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 năm cách đây
The will not start if two plugins has a same different external DLL file.
Example
This plugin Misc.Sendinblue uses the library RestSharp.dll (106.12.0.0)
Try to install the another plugin with the the library RestSharp.dll (106.4.2.0)
It's important!!!
The second plugin has the different version of the RestSharp.dll (old or new one).
We'll see this error message
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'RestSharp, Version=106.12.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75'. Could not find or load a specific file. (0x80131621)
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.Extensions.DependencyInjection.MvcCoreMvcBuilderExtensions.AddControllersAsServices(IMvcBuilder builder)
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.AddNopMvc(IServiceCollection services)
   at Nop.Web.Framework.Infrastructure.NopMvcStartup.ConfigureServices(IServiceCollection services, IConfiguration configuration)
   at Nop.Core.Infrastructure.NopEngine.ConfigureServices(IServiceCollection services, IConfiguration configuration)
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder)
   at Program.<Main>$(String[] args)
System.IO.FileLoadException: Could not load file or assembly 'RestSharp, Version=106.12.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75'. Could not find or load a specific file. (0x80131621)
File name: 'RestSharp, Version=106.12.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75'
---> System.IO.FileLoadException: Could not load file or assembly 'RestSharp, Version=106.12.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75'.
   at System.Runtime.Loader.AssemblyLoadContext.<LoadFromPath>g____PInvoke|5_0(IntPtr ptrNativeAssemblyBinder, UInt16* ilPath, UInt16* niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)


I think we need to load the site but to write to nopcommerce log the information that the second plugin didn't install (or the plugin didn't upgrade).
The store's owner could upload plugins from different vendors with different external DLL files.
1 năm cách đây
This is a known issue (see here). At the moment there is no solution for it.
All our out-of-the-box plugins are compatible, but we cannot guarantee that third-party plugins will use the same dll versions.
1 năm cách đây
I want to remove the crash screen.
We needn't load two plugins with different external DLL files.
The store's owner installed the first plugin and installed it.
The store's owner tried to install the second plugin. Nopcommerce checks the version of external plugin and showed the warning message.
It's user friendly.
Thank you for your help.
1 năm cách đây
Hi. We liked your idea and we are already finishing its implementation, you can already evaluate its functionality in this thread. Soon we will merge it into the main code and it will be included in the next minor release for 4.60

foxnetsoft wrote:
I want to remove the crash screen.
We needn't load two plugins with different external DLL files.
The store's owner installed the first plugin and installed it.
The store's owner tried to install the second plugin. Nopcommerce checks the version of external plugin and showed the warning message.
It's user friendly.
Thank you for your help.
1 năm cách đây
Thank you
1 năm cách đây
Hi,

I believe that I have an issue with the the related commit (https://github.com/nopSolutions/nopCommerce/commit/b493a2a47375dddceb857ed35be6eeef3cb2b36c#diff-cb688898e76fc9506dc581e83cec87c5e796c98d11836e233c6aa6ff96754ded) and specifically to ApplicationPartManagerExtensions.cs is that the implementation of Dictionary means that there can be no duplicate keys for assemblies.  In my instance, when nop spins up on the server it throws an unhandled exception when trying to add multiple Dlls with the same name (e.g. Microsoft.Data.SqlClient.dll exists in both BaseDirectory/CurrentDirectory and 'refs' folder).  

My deployment is framework-dependent with a portable target runtime on Azure VM.  I did a full clean publish to Azure and had duplicate Dlls reported by Event Viewer - even when iteratively manually comparing and removing suspect Dlls.  I changed my code from Dictionary back to List and there was no issue running nop.

The exception can be found below.

Kind regards,

***** begin exception

Application '/LM/W3SVC/1/ROOT' with physical root 'C:\inetpub\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions' threw an exception.
---> System.ArgumentException: An item with the same key has already been added. Key: AdvancedStringBuilder.dll
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions..cctor() in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 49
   --- End of inner exception stack trace ---
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 230
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs:line 96
   at Program.<Main>$(String[] args) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web\Program.cs:line 38
**** end exception
1 năm cách đây
Hi.  I fixed such problem in this commit.  Thank you for sharing your experience
webie wrote:
Hi,

I believe that I have an issue with the the related commit (https://github.com/nopSolutions/nopCommerce/commit/b493a2a47375dddceb857ed35be6eeef3cb2b36c#diff-cb688898e76fc9506dc581e83cec87c5e796c98d11836e233c6aa6ff96754ded) and specifically to ApplicationPartManagerExtensions.cs is that the implementation of Dictionary means that there can be no duplicate keys for assemblies.  In my instance, when nop spins up on the server it throws an unhandled exception when trying to add multiple Dlls with the same name (e.g. Microsoft.Data.SqlClient.dll exists in both BaseDirectory/CurrentDirectory and 'refs' folder).  

My deployment is framework-dependent with a portable target runtime on Azure VM.  I did a full clean publish to Azure and had duplicate Dlls reported by Event Viewer - even when iteratively manually comparing and removing suspect Dlls.  I changed my code from Dictionary back to List and there was no issue running nop.

The exception can be found below.

Kind regards,

***** begin exception

Application '/LM/W3SVC/1/ROOT' with physical root 'C:\inetpub\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions' threw an exception.
---> System.ArgumentException: An item with the same key has already been added. Key: AdvancedStringBuilder.dll
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions..cctor() in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 49
   --- End of inner exception stack trace ---
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 230
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs:line 96
   at Program.<Main>$(String[] args) in D:\users\mw\source\repos\webiesoftware\nopCommerceMirror\src\Presentation\Nop.Web\Program.cs:line 38
**** end exception
1 năm cách đây
Hi,

Thanks for putting in a fix, but when trying to load a non-IL assembly (e.g. Microsoft.AspNetCore.Antiforgery.DLL) the LoadFile() method fails and throws BadImageFormatException.  Perhaps the Load() method needs to be called for non-IL assemblies?

Exception example is below.

Kind regards,

***** exception start

Application: w3wp.exe
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for 'Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions' threw an exception.
---> System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Reference assemblies cannot be loaded for execution. (0x80131058)
File name: 'Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFile(String path)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions..cctor() in D:\users\*****\source\repos\*****\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 55

***** exception end
1 năm cách đây
Hi. I don’t know how such assemblies get into your plugins, I was able to repeat this behavior by disabling the assembly cleaning mechanism, however, I redid the algorithm, the problem should no longer be.
webie wrote:
Hi,

Thanks for putting in a fix, but when trying to load a non-IL assembly (e.g. Microsoft.AspNetCore.Antiforgery.DLL) the LoadFile() method fails and throws BadImageFormatException.  Perhaps the Load() method needs to be called for non-IL assemblies?

Exception example is below.

Kind regards,

***** exception start

Application: w3wp.exe
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for 'Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions' threw an exception.
---> System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Reference assemblies cannot be loaded for execution. (0x80131058)
File name: 'Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFile(String path)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions..cctor() in D:\users\*****\source\repos\*****\nopCommerceMirror\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 55

***** exception end
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.