Inheritance security rules violated by type: "System.Net.Http.WebRequestHandler"

I have an assembly reference in the web.config file of an MVC application ...

<dependentAssembly>
  <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.0.0.0" />
</dependentAssembly>

      

Every time I install or update any nuget package the version number is automatically updated to 4.1.1.0. However, this breaks my application completely. It displays an error ...

Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler. Derived types must either match the accessibility security of the base type or less accessible.

I found other questions where the suggested solution is to change the version number back. This, however, does not seem particularly satisfying. There must be some underlying problem that forces me to always use the old version of this module. I am trying to find the right solution and not just constantly hack it to make it work.

Does anyone know what is actually causing this and know the correct way to fix it using the recommended versions of all packages?

+3


source to share


4 answers


The solution turned out to be much simpler than I expected. I completely removed the System.Net.Http link from web.config and now it works correctly.



+1


source


I saw this error trying to instantiate KeyVaultClient. I was able to fix this by installing the nuget package System.Net.Http v4.3.2.



+2


source


You can also check to see if you have "Skip bind redirection" in your options.

Visual studio updates the web.config file as a result if not installed.

0


source


It must be a System.Net.Http issue. I ran my code in VS 2015, it threw excpetion Then I ran my code in VS 2017, it worked.

0


source







All Articles