Issue
When trying to publish a workflow the publish fails with: Loading this assembly would produce a different grant set from other instances.
Error Code
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
Resolution
Contact Microsoft support as this is caused by using SCOM with Client-side .NET Application Performance Monitoring (APM) in a SharePoint farm, which is not supported.
Additional Information
The following blog post explains the ***unsupported*** way to resolve the issue. Extracted steps are below the link.
http://blog.bugrapostaci.com/2017/02/08/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401/
1) Uninstall the SCOM Agent manually on the SharePoint Servers.
2) Delete the “C:Program FilesMicrosoft Monitoring Agent” folder on your SharePoint Servers.
3) Copy the SCOM Agent folder from your SCOM Management Server to the SharePoint Servers. The Agent folder can be found under C:Program FilesMicrosoft System Center 2012 R2Operations ManagerServerAgentManagementamd64 on your SCOM Management Servers.
4) Open an elevated cmd window and on your SharePoint Server and install the SCOM Agent manually with the NOAPM=1 switch like in the example below.
Example : msiexec /i momagent.msi NOAPM=1
5) Afterwards please kindly install your Update Rollups. The current installed Update Rollup on your SCOM Management Server is also inside the Agent folder available.
C:Program FilesMicrosoft System Center 2012 R2Operations ManagerServerAgentManagementamd64
Related Links
