@bobnoordam

Loading this assembly would produce a different grant set from other instances

Visual studio outputs this message during build. when updating nuget packages, in a log message more or less like this:

Executing nuget actions took 3,16 sec
Removed package 'Asterix.Framework.Runtime 24.43.0.4' from 'packages.config'
Successfully uninstalled 'Asterix.Framework.Runtime 24.43.0.4' from Asterix.Server.Mysqlbridge
Package 'Asterix.Framework.Runtime.24.45.0.2' already exists in folder 'C:\Git\asterixmonorepo\framework\products\obelix\packages'
Added package 'Asterix.Framework.Runtime.24.45.0.2' to 'packages.config'
Successfully installed 'Asterix.Framework.Runtime 24.45.0.2' to Asterix.Server.Mysqlbridge
Failed to update binding redirects for Asterix.Server.Mysqlbridge\Asterix.Server.Mysqlbridge.csproj : Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
Executing nuget actions took 699 ms

Resolution:

Create a new registry DWORD value called LoaderOptimization and give it the value 1 within the key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework”.

see also: https://stackoverflow.com/questions/42240956/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances

see also: https://learn.microsoft.com/en-us/archive/msdn-technet-forums/5db05238-3c12-4e7e-af95-ca56545f0721

see also: https://blog.bugrapostaci.com/2017/02/08/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401/