违反类型的继承安全性规则:'System.Net.Http.WebRequestHandler' [英] Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'

查看:311
本文介绍了违反类型的继承安全性规则:'System.Net.Http.WebRequestHandler'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC应用程序的web.config中具有以下程序集引用...

I have the following assembly reference in the web.config 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>

每次我安装或更新任何nuget软件包时,版本号都会自动更新为4.1.1.0.但是,这完全破坏了我的应用程序.它显示错误...

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

违反类型的继承安全性规则: 'System.Net.Http.WebRequestHandler'.派生类型必须匹配 基本类型的安全性可访问性或不可访问性.

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

我发现了其他问题,其中建议的解决方案是再次更改版本号.但是,这似乎并不特别令人满意.必须存在一些潜在的问题,导致我不得不始终使用该模块的旧版本.我正在尝试寻找合适的解决方案,而不是仅仅不断对其进行破解以使其起作用.

I've found other questions, where the proposed solution is to change the version number back again. This however doesn't seem particularly satisfactory. There must be some underlying problem that's causing me to have to always use an old version of this module. I'm trying to find a proper solution, rather than just continually hacking it to make it work.

有人知道真正的原因是什么,并且知道使用所有软件包的推荐版本来解决此问题的正确方法吗?

Does anyone know what actually causes this, and know a correct way to fix it using recommended versions of all packages?

推荐答案

该解决方案比我预期的要简单得多.我从web.config中完全删除了System.Net.Http引用,现在它可以正常工作.

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

这篇关于违反类型的继承安全性规则:'System.Net.Http.WebRequestHandler'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆