I’m writing this post as a reminder to myself on how to fix the following error message …
Attempted to access an element as a type incompatible with the array
… when firing up a Web Api project which is using Thinktecture IdentityModel.
My initialisation code looks like this …
var authenticationConfig = CreateAuthenticationConfiguration(); var handler = new AuthenticationHandler(authenticationConfig); configuration.MessageHandlers.Add(handler);
The problem is caused by the wrong version of the System.Net.Http being used. The solution is to remove the bindingRedirect you see below.
<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-188.8.131.52" newVersion="184.108.40.206" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Note to future me: You will eventually remember this without having to come and look at this blog post!