VS2010中打开项目中的Winform界面报“This method explicitly users CAS policy,which has been obsoleted by the ...”

问题描述

  某程序从.net framework3.5升级到.net framework4.0,开发工具从VS2008升级到VS2010。进行功能测试期间,发现在VS2010中打开部分Winform界面报错,错误信息为“This method explicitly uses CAS policy,which has been obsoleted by the .NET Framework.In order to enable CAS policy for compatibility reasons,please use the NetFx40_LegacySecurityPolicy configuration switch.Please see http://go microsoft.com/fwlink/?LinkID=155570 for more information.”。报错之后,无法进入Winform设计界面。

解决方案

  程序由一组人员维护,程序升级后,有2个人的VS2010报上述错误,其它人的都可以正常使用。通过百度错误信息,发现有不少人遇到类似的问题,本文收录了两篇解决方案的文章,详见参考文献。
  解决方法比较简单,在VS2010的安装目录下的Common7\IDE文件夹中找到devenv.exe.config文件。打开该文件,在<runtime>标签下增加 <NetFx40_LegacySecurityPolicy enabled=“true”/>子标签,如下图所示。
VS2010中打开项目中的Winform界面报“This method explicitly users CAS policy,which has been obsoleted by the ...”
  保存devenv.exe.config文件,重新打开VS2010即可解决问题。

参考文献:
[1]https://blog.csdn.net/afeyfre41671/article/details/102262060?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control
[2]https://blog.csdn.net/cdm419/article/details/8251866

上一篇:利用蒙特卡洛方法实现21点问题的最优解(内含python源码)


下一篇:reinforcement learning