after a while I have some problem with my self developed plugins but after some research I found that it belong to nopCommerce issue that exist in v4
I saw this topic (Serious IIS Application Pool recycling bug/design flaw) and other related topics ad also I saw this issue(Assembly blocking on application startup)
At the first my plugin config in appSettings.json was like below:
"PluginConfig": {
"ClearPluginShadowDirectoryOnStartup": true,
"CopyLockedPluginAssembilesToSubdirectoriesOnStartup": true,
"UseUnsafeLoadAssembly": true,
"UsePluginsShadowCopy": true
}
and I get this error in my stdout log file:
Unhandled exception. System.Exception: Plugin 'Daya Sms'. Access to the path 'C:\inetpub\Websites\Test.Rees.ir\Plugins\bin\Nop.Plugin.Communication.Daya.Sms.dll' is denied.
Access to the path 'C:\inetpub\Websites\Test.Rees.ir\Plugins\bin\Nop.Plugin.Communication.Daya.Sms.dll' is denied.
---> System.Exception: Plugin 'Daya Sms'. Access to the path 'C:\inetpub\Websites\Test.Rees.ir\Plugins\bin\Nop.Plugin.Communication.Daya.Sms.dll' is denied.
---> System.UnauthorizedAccessException: Access to the path 'C:\inetpub\Websites\Test.Rees.ir\Plugins\bin\Nop.Plugin.Communication.Daya.Sms.dll' is denied.
at System.IO.FileSystem.DeleteFile(String fullPath)
at System.IO.File.Delete(String path)
at Nop.Core.Infrastructure.NopFileProvider.DeleteFile(String filePath) in C:\andrei\nop_sources\src\Libraries\Nop.Core\Infrastructure\NopFileProvider.cs:line 153
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.ShadowCopyFile(INopFileProvider fileProvider, String assemblyFile, String shadowCopyDirectory) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 104
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.PerformFileDeploy(ApplicationPartManager applicationPartManager, String assemblyFile, String shadowCopyDirectory, PluginConfig pluginConfig, INopFileProvider fileProvider) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 206
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 503
--- End of inner exception stack trace ---
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 539
--- End of inner exception stack trace ---
at Nop.Web.Framework.Infrastructure.Extensions.ApplicationPartManagerExtensions.InitializePlugins(ApplicationPartManager applicationPartManager, PluginConfig pluginConfig) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationPartManagerExtensions.cs:line 550
at Nop.Web.Framework.Infrastructure.Extensions.ServiceCollectionExtensions.ConfigureApplicationServices(IServiceCollection services, WebApplicationBuilder builder) in C:\andrei\nop_sources\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs:line 68
at Program.<Main>$(String[] args) in C:\andrei\nop_sources\src\Presentation\Nop.Web\Program.cs:line 19
and based on mentioned topic, I set
UsePluginsShadowCopyto false and everything was ok to my website but after some days I decided to update my plugins and when I upload the first one I got this error:
همه پیام ها
System.UnauthorizedAccessException: Access to the path 'Nop.Plugin.Misc.Daya.CustomerClub.dll' is denied.
at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
at Nop.Core.Infrastructure.NopFileProvider.DeleteDirectoryRecursive(String path) in C:\andrei\nop_sources\src\Libraries\Nop.Core\Infrastructure\NopFileProvider.cs:line 36
at Nop.Core.Infrastructure.NopFileProvider.DeleteDirectory(String path) in C:\andrei\nop_sources\src\Libraries\Nop.Core\Infrastructure\NopFileProvider.cs:line 140
at Nop.Services.Plugins.UploadService.UploadMultipleItems(String archivePath, IList`1 uploadedItems) in D:\NopCommerce Development\nopCommerce_4.50.4_Source\Libraries\Nop.Services\Plugins\UploadService.cs:line 229
at Nop.Services.Plugins.UploadService.UploadPluginsAndThemes(IFormFile archivefile) in D:\NopCommerce Development\nopCommerce_4.50.4_Source\Libraries\Nop.Services\Plugins\UploadService.cs:line 327
at Nop.Web.Areas.Admin.Controllers.PluginController.UploadPluginsAndThemes(IFormFile archivefile) in C:\andrei\nop_sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\PluginController.cs:line 171
and I forced to set
UsePluginsShadowCopyto true again to able to upload my plugins and after every upload I get HTTP Error 500.30 - ASP.NET Core app failed to start error and I should to stop my site on IIS and recycle my application pool and then start my website to work.
So what should we do for avoiding this serious bug?
If we set
UsePluginsShadowCopyto false we could not to upload plugin and If we set it to true out application could not start after application pool overlapped recycling
Does anyone have any idea to solve this?