Home Dashboard Directory Help
Search

System.NotSupportedException: This method explicitly uses CAS policy, which has been obsoleted by the .Net Framework by Sheng Jiang 蒋晟


Status: 

Closed
 as By Design Help for as By Design


3
0
Sign in
to vote
Type: Bug
ID: 509613
Opened: 11/10/2009 12:22:15 PM
Access Restriction: Public
2
Workaround(s)
view
1
User(s) can reproduce this bug

Description

Visual Studio 2010 & .Net Framework 4 binaries need to turn on NetFx40_LegacySecurityPolicy in config file for .Net 4.0 code that references assemblies that explicitly uses the CAS policy.

A related discussion about the Windows SDK tool lc.exe is at
http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/a3c897c6-e816-460b-b74d-b683ea033a2d
Details
Sign in to post a comment.
Posted by Mladen Mihajlovic on 7/12/2010 at 2:45 AM
We had this issue opening forms using DevExpress 8.3.4 controls. The thing is that our project is targeted to use the .NET framework ver 3 and not 4 but the error still came up when opening the forms. I added the NetFx40_LegacySecurityPolicy to my machine.config file for the ver 4 framework and it works now, but I still think it should not be doing this.
Posted by Microsoft on 11/19/2009 at 11:31 AM
Hi Sheng,

Thank you for reporting this issue to us - I was able to get more information around this issue from your forum post [http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/a3c897c6-e816-460b-b74d-b683ea033a2d]. The issue here is that your Winforms project (mentioned in the forum post) utilizes controls that use Code Access Security (CAS) Policy APIs. These APIs have been deprecated as runtime-wide CAS Policy is no longer enforced in .NET Framework 4.

Our SDK tools don't use the CAS policy APIs themselves, so it wouldn't be appropriate for the tools themselves to set the compatibility flag (which is first and foremost a migration mechanism). Therefore, the real solution is for those controls to move off of their dependency on CAS policy; I've already sent mail to the control owners regarding this.

Thank you,
Andrew Dai
Microsoft Corporation - CLR Security
Posted by Microsoft on 11/13/2009 at 4:32 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by Microsoft on 11/11/2009 at 3:17 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by André Oliveira - GO on 7/6/2012 at 7:59 AM
Para resolver o problema é necessário liberar o acesso da política CAS.
Para isso faça o seguinte:

Adicione o código em <trust web.config level="Full" aplicação legacyCasModel="true"/> dentro do <system.web> tag.

<system.web>
        <trust level="Full" legacyCasModel="true"/>
</ system.web>
Posted by Sheng Jiang 蒋晟 on 11/10/2009 at 12:27 PM
If any Visual Studio binary /.Net Framework SDK tool throws this error
open filename.exe.config file while filename is the name of the binary (create one if no one exists)
Enable NetFx40_LegacySecurityPolicy as described in http://msdn.microsoft.com/en-us/library/dd409253(VS.100).aspx