Publishing Service update crashes Sitecore XP instance


Description

When updating Sitecore Publishing Service (SPS), an error occurs due to incorrect references to some assemblies. For example, System.Net.Http and System.Diagnostics.DiagnosticSource assemblies cannot be loaded after upgrading the SPS module to 3.1.3 version with installed .NET Framework 4.7.0 or earlier. The following exceptions appear in logs:

System.IO.FileLoadException: Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
...
Exception: Sitecore.Framework.Publishing.Client.Http.HttpServiceResponseException
Message: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This issue affects Sitecore Publishing Service 3.1 Update-3.

Solution

To resolve the issue, consider one of the following options: