Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SecurityAction.RequestMinimum is obsolete in .Net 4.0

Recently, our .Net client libaray is upgrading to compile against Net 4.0. After change the target framework to 4.0, the application has some compilation error.

In AssemblyInfo.cs:

[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)]

Error 7 Warning as Error: 'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete: '"Assembly level declarative security is obsolete and is no longer enforced by the CLR by default. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information."' `

In .Net 4.0, it shows that: SecurityAction.RequestMinimum as obsolete, and we treat all warning as error.

What I should do with it? - Just remove it(will this has some unexpected impact? for example when the dlls are used in IIS) or change to some other value? I am not familiar with .Net, especially its security mechanism.

Anyone can help on this? Thanks for any advice and comment :)

like image 936
jeffery.yuan Avatar asked Jul 24 '12 06:07

jeffery.yuan


2 Answers

From MSDN:

In the .NET Framework version 4, runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests. These requests should not be used in code that is based on .NET Framework 4 or later.

So, just remove it.

like image 155
Centro Avatar answered Nov 15 '22 23:11

Centro


Some searching led me here for a similar VB.net rdlc error (so yes, I know the question was tagged C#). I did not utilize the offending code, but I did find that a stray underscore caused this error, for example: in a textbox expression you might accidentally put:

"This is a " & _
"test"

thinking you are in some code behind, but alas this generates this same error as listed above and once removed, the error was gone.

like image 26
SkeletonJelly Avatar answered Nov 15 '22 23:11

SkeletonJelly