Assembly mismatch despite having assembly redirect and loading correct version

前端 未结 2 851
粉色の甜心
粉色の甜心 2021-02-14 03:08

My console app uses System.Net.Http.Formatting v5.1.0.0 that depends on Newtonsoft.Json v4.5.0.0. My app however includes v6.0.0.0 of Newtonsoft.Json (for other reasons).

<
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 03:13

    Just wanted to add a small amount of additional detail here, since this is a particularly nasty problem and garlic, silver bullets, and holy water are in short supply.

    We ran into this recently and discovered that the cause was schema-violating XML in the app.config resulting from a bad auto-merge, e.g.

    
            
            
            
            
    
    

    We didn't notice the problem in the file since it's still technically valid XML and the Visual Studio parser never complained.

    The runtime binding routine, however, refused to apply any of the binding redirects (even ones stated outside of the malformed section). Furthermore, as alluded to above, there is no indication in the fusion logs that the runtime failed to parse the config file. It sees the correct dlls and config file location but still fails with a minor version discrepancy as if there was never any redirect applied.

    TL;DR - If you're getting this behavior, check to see that your config file XML is 100% perfect -- and don't trust that the squiggly lines in VS will reveal every possible problem.

提交回复
热议问题