Assembly with the same name is already loaded

Hace 7 meses
Hello,
Getting this error when deploying to Azure using App Service.

Application '/LM/W3SVC/518711467/ROOT' with physical root 'C:\home\site\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.Exception: Assembly with same name is already loaded

---> System.IO.FileLoadException: Assembly with same name is already loaded
   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 Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.AddApplicationParts(ApplicationPartManager applicationPartManager, String assemblyFile, Boolean useUnsafeLoadAssembly) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 146
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.PerformFileDeploy(ApplicationPartManager applicationPartManager, String assemblyFile, PluginConfig pluginConfig, INopFileProvider fileProvider) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 175
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 284
   --- End of inner exception stack trace ---
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 329
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs:line 96
   at Program.<Main>$(String[] args) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web\Program.cs:line 38

Process Id: 8948.
File Version: 17.0.23170.8. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 3c37ef8f5358abb303c05d299f029fca7d867d56

Everything was working fine until I added a dependency to a custom plugin we developed in house.
The dependency is the official Nop Web Api Backend.
https://ibb.co/smg8JLP
Hace 7 meses
Set copy local - NO to the new dependency you added.
Then delete the plugins folder from Azure (it will remove all of the duplicate dlls) and deploy the full project again.
Hace 7 meses
Hi. I saw your message in issue #6828. All I can say in addition to my previous message is that the plugin is not just a class library, it also works with DI, routes, and much more. If you want to extend the standard behavior of a plugin, it is best to make changes directly to the plugin itself. As another option, you can create your own API plugin, which will call the main methods if necessary. To protect such a plugin from unwanted deletions of the associated plugin, we added the DependsOnSystemNames setting to the plugin.json file.


jjcowo wrote:
Hello,
Getting this error when deploying to Azure using App Service.

Application '/LM/W3SVC/518711467/ROOT' with physical root 'C:\home\site\wwwroot\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception. System.Exception: Assembly with same name is already loaded

---> System.IO.FileLoadException: Assembly with same name is already loaded
   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 Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.AddApplicationParts(ApplicationPartManager applicationPartManager, String assemblyFile, Boolean useUnsafeLoadAssembly) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 146
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.PerformFileDeploy(ApplicationPartManager applicationPartManager, String assemblyFile, PluginConfig pluginConfig, INopFileProvider fileProvider) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 175
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 284
   --- End of inner exception stack trace ---
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 329
   at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs:line 96
   at Program.<Main>$(String[] args) in C:\Users\TravisMyvett\source\repos\nopCommerce_4.60.3\src\Presentation\Nop.Web\Program.cs:line 38

Process Id: 8948.
File Version: 17.0.23170.8. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 3c37ef8f5358abb303c05d299f029fca7d867d56

Everything was working fine until I added a dependency to a custom plugin we developed in house.
The dependency is the official Nop Web Api Backend.
https://ibb.co/smg8JLP
Hace 7 meses
Setting Copy Local to No throws a new error that it is unable to load assembly.
Hace 7 meses
Check the display order in the plugin.json of your custom plugin. It should be higher than the plugin it depends on. This way your plugin will load after that plugin it depends on.