关于visual studio 2010 此方法显式使用的 CAS 策略已被 .NET Framework 弃用 的问题

GDY__GDY 2011-08-03 10:59:04
大家好,我在vs2010中使用了DevExpress组件,我在用Visual studio 2010从工具箱中向窗口拖动控件时显示如下提示:

创建组件“ToolTipController”失败。错误消息为:
“System.TypeInitializationException: “DevExpress.Utils.AppearanceObject”的类型初始值设定项引发异常。 ---> System.NotSupportedException: 此方法显式使用的 CAS 策略已被 .NET Framework 弃用。若要出于兼容性原因而启用 CAS 策略,请使用 NetFx40_LegacySecurityPolicy 配置开关。有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkID=155570。
在 System.Security.SecurityManager.ResolvePolicy(Evidence evidence)
在 DevExpress.Data.Helpers.SecurityHelper.IsPermissionGranted(IPermission permission)
在 DevExpress.Utils.Design.DXAssemblyResolverEx.Init()
在 DevExpress.Utils.AppearanceObject..cctor()
--- 内部异常堆栈跟踪的结尾 ---
在 DevExpress.Utils.ToolTipControllerShowEventArgs..ctor(Control control, Object obj, Object dummy)
在 DevExpress.Utils.ToolTipController..ctor()”


经上网查询,说是CAS(代码访问安全)在.net frame work 4.0中改了,不是像以前版本的framework那样了,就因为有这个限制拖动控件的时候才有这个警告,但是拖动System.Window.Form下原有的控件,比如按钮什么的是不会报错的,通过网上的意见我在程序的App.config中添加了如下的内容:
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
不幸的是问题依旧啊,请问以前用过vs2010的,这个怎么解决啊,谢谢了,很急
...全文
2185 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
ming_qz 2013-09-22
  • 打赏
  • 举报
回复
楼主的方法是错误的.修改CAS不是在APP.config文件. 13楼才是正确的.试了行.
chollima20080808 2013-07-11
  • 打赏
  • 举报
回复
13楼的方法是微软官方发布的方法,但是添加这个之后会导致编译出现问题,我删掉NetFx40_LegacySecurityPolicy节点,编译ok,在添加进去,在编译也ok。但代码一旦修改,必须删掉此节点才能编译通过
程序员一枚 2013-06-17
  • 打赏
  • 举报
回复
13楼正解
a12321321321312321 2012-06-05
  • 打赏
  • 举报
回复
vs2012 用最新版本吧,我用的11.1.8。用老版本的控件在08里面没问题,在10里面就会有问题。
Fs_2011 2012-06-05
  • 打赏
  • 举报
回复
看来这个问题大家都遇到过啊,那有没有解决的啊,2楼13楼的不可以啊
mypurpleing 2012-03-19
  • 打赏
  • 举报
回复

<NetFx40_LegacySecurityPolicy enabled="true"/>
作为第一项添加到C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config文件中的<runtime>标签下,保存文件。
以实验过,可行。
友情提醒:上述文件目录需根据自己安装文件的位置在相应目录下找到,不是固定的。
hezi168 2012-02-12
  • 打赏
  • 举报
回复
在vs2010中,
根据http://stackoverflow.com/questions/2637089/netfx40-legacysecuritypolicy-in-design-time-mode
可以调试,也可以开始执行(不调试),

但是当发布到iis 后 ,不知如何配置, 报出的错误为:::(出现此方法显式使用的 CAS 策略已被 .NET Framework 弃用。若要出于兼容性原因而启用 CAS 策略,请使用 NetFx40_LegacySecurityPolicy 配置开关。有关详细信息,请参见 http://go.microsoft.com/fwlink/?LinkID=155570。)


请问如何解决
tobypy 2012-02-08
  • 打赏
  • 举报
回复
vs2010调试是正常的。发布后就出现这个问题了。有人解决吗?
xgcdd 2011-12-31
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/en-us/library/ee191568(VS.100).aspx
xgcdd 2011-12-31
  • 打赏
  • 举报
回复
Copy
<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>
ningxikui2 2011-11-30
  • 打赏
  • 举报
回复
我也遇到同样的问题,还有其他解决办法吗?
zhangviv 2011-10-23
  • 打赏
  • 举报
回复
我也遇到同样问题啊,试了上面的两种我都没有解决,有其他解决方法么?
zzl4251 2011-09-27
  • 打赏
  • 举报
回复
二楼的好用,已解决.
fenzhijie 2011-09-20
  • 打赏
  • 举报
回复
哪位兄弟搞定了帮忙贴一下呀,期待解决方案
zhangyf58589 2011-09-11
  • 打赏
  • 举报
回复
2楼的大哥,有解决方案了么?
zhangyf58589 2011-09-11
  • 打赏
  • 举报
回复
我也遇到这个问题,顶一下
GDY__GDY 2011-09-01
  • 打赏
  • 举报
回复
这个我还真忘记了,最后解决了,你先用这个方法看看:在“解决方案”的“工程”上点击鼠标右键,选“属性”,然后选“应用程序”标签,里面有一个叫“目标框架”的选项,然后将其从“.net Framework4 client profile”改为".net Framework 4",时间长了我忘记是不是这个方法了,如果这个方法不对,以后想起来 一定回来回帖的
tanglei932 2011-08-25
  • 打赏
  • 举报
回复
这个问题很着急啊!有没有已经解决的?给提个解决办法
编程实例 MICROSOFT SOFTWARE LICENSE TERMS Microsoft Visual Studio 2005 and .NET Framework 2.0 Samples These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft * updates, * supplements, * Internet-based services, and * support services for this software, unless other terms accompany those items. If so, those terms apply. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE. If you comply with these license terms, you have the rights below. 1. INSTALLATION AND USE RIGHTS. You may install and use any number of copies of the software on your devices. 2. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS. a. Distributable Code. The software contains code that you are permitted to distribute in programs you develop if you comply with the terms below. i. Right to Use and Distribute. The code and text files listed below are 揇istributable Code.? * Sample Code. You may modify, copy, and distribute the source and object code form of the sample source code included in the subfolders of the project files. * Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs. ii. Distribution Requirements. For any Distributable Code you distribute, you must * add significant primary functionality to it in your programs; * require distributors and external end users to agree to terms that protect it at least as much as this agreement; * display your valid copyright notice on your programs; and * indemnify, defend, and hold harmless Microsoft from any claims, including attorneys?fees, related to the distribution or use of your programs. iii. Distribution Restrictions. You may not * alter any copyright, trademark or patent notice in the Distributable Code; * use Microsoft抯 trademarks in your programs?names or in a way that suggests your programs come from or are endorsed by Microsoft; * distribute Distributable Code to run on a platform other than the Windows platform; * include Distributable Code in malicious, deceptive or unlawful programs; or * modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that * the code be disclosed or distributed in source code form; or * others have the right to modify it. 3. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not * work around any technical limitations in the software; * reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation; * make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation; * publish the software for others to copy; * rent, lease or lend the software; * transfer the software or this agreement to any third party; or * use the software for commercial software hosting services. 4. BACKUP COPY. You may make one backup copy of the software. You may use it only to reinstall the software. 5. DOCUMENTATION. Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes. 6. EXPORT RESTRICTIONS. The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting. 7. SUPPORT SERVICES. Because this software is 揳s is,?we may not provide support services for it. 8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services. 9. APPLICABLE LAW. a. United States. If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort. b. Outside the United States. If you acquired the software in any other country, the laws of that country apply. 10. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so. 11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED 揂S-IS.? YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. This limitation applies to * anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and * claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages. Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French. Remarque : Ce logiciel 閠ant distribu?au Qu閎ec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en fran鏰is. EXON蒖ATION DE GARANTIE. Le logiciel vis?par une licence est offert ?tel quel ? Toute utilisation de ce logiciel est ?votre seule risque et p閞il. Microsoft n抋ccorde aucune autre garantie expresse. Vous pouvez b閚閒icier de droits additionnels en vertu du droit local sur la protection dues consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualit?marchande, d抋d閝uation ?un usage particulier et d抋bsence de contrefa鏾n sont exclues. LIMITATION DES DOMMAGES-INT蒖蔜S ET EXCLUSION DE RESPONSABILIT?POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement ?hauteur de 5,00 $ US. Vous ne pouvez pr閠endre ?aucune indemnisation pour les autres dommages, y compris les dommages sp閏iaux, indirects ou accessoires et pertes de b閚閒ices. Cette limitation concerne : * tout ce qui est reli?au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et * les r閏lamations au titre de violation de contrat ou de garantie, ou au titre de responsabilit?stricte, de n間ligence ou d抲ne autre faute dans la limite autoris閑 par la loi en vigueur. Elle s抋pplique 間alement, m阭e si Microsoft connaissait ou devrait conna顃re l掗ventualit?d抲n tel dommage. Si votre pays n抋utorise pas l抏xclusion ou la limitation de responsabilit?pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l抏xclusion ci-dessus ne s抋ppliquera pas ?votre 間ard. EFFET JURIDIQUE. Le pr閟ent contrat d閏rit certains droits juridiques. Vous pourriez avoir d抋utres droits pr関us par les lois de votre pays. Le pr閟ent contrat ne modifie pas les droits que vous conf鑢ent les lois de votre pays si celles ci ne le permettent pas.

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧