用vs2008開發的應用程序在vs2012中打開時提示如下:
此方法顯式使用的 CAS 策略已被 .NET Framework 棄用。若要出於兼容性原因而啟用 CAS 策略,請使用 NetFx40_LegacySecurityPolicy 配置開關。
從網上搜索了相關資料,查看了微軟幫助文件 ,提到的方法大致兩種 :
1、在vs默認安裝目錄下的C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config中添加
<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>
本地試過此種方法,不管用。
2、在應用程序的配置文件 web.config中添加:
<system.web>
<trust level="Full" legacyCasModel="true"/>
</system.web>
添加后,應用程序正常運行。