-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
PostSharp's build-time compiler fails to load its bundled Newtonsoft.Json when a different binary of the same assembly (same version 13.0.0.0, same public key token, but different build) is registered in the GAC. The CLR rejects the load with error 0x80131050.
Root Cause
PostSharp ships its own copy of Newtonsoft.Json 13.0.0.0 in its installation directory. At build time, the PostSharp compiler (running as a 64-bit process) attempts to load this bundled copy. However, the CLR detects that an assembly with the same identity (version + public key token) but different binary content already exists in the GAC, and refuses to load the PostSharp-bundled copy.
The AMD64 reference visible in PostSharp logs is a red herring — it is just the first GAC probe attempt by PostSharp's internal assembly resolution. It falls back to MSIL, which is the actual GAC entry.
Reproduction
- Have
Newtonsoft.Json 13.0.0.0registered in the GAC (e.g., installed by another application). - Build a project with PostSharp — the build fails with error
0x80131050. - The issue does not occur on machines where
Newtonsoft.Jsonis not in the GAC.
Workarounds
- Remove
Newtonsoft.Jsonfrom the GAC. - Replace the GAC copy with the exact binary that PostSharp bundles (may break other GAC consumers).
Possible Fixes
- Investigate whether
Newtonsoft.Jsonstill needs to be bundled with PostSharp. - Give priority to GAC copies over PostSharp's bundled copies.
- Mask this assembly from the GAC during PostSharp's assembly resolution.