Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt by security transparent method to access security critical method failed

Tags:

c#

asp.net

paypal

Attempt by security transparent method 'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()' to access security critical method 'System.Management.ManagementObjectSearcher..ctor(System.String)' failed.

Assembly 'PayPalCoreSDK, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself.  In order to access security critical code, this assembly must be fully trusted.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MethodAccessException: Attempt by security transparent method 'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()' to access security critical method 'System.Management.ManagementObjectSearcher..ctor(System.String)' failed.

Assembly 'PayPalCoreSDK, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself.  In order to access security critical code, this assembly must be fully trusted.

This stackoverflow answer mentions adding the [SecuritySafeCritical] attribute to the class, but in this case the class at play is in a DLL loaded through NuGet.

Are there any global settings I can use to bypass this exception?

like image 613
Zerkey Avatar asked Nov 27 '13 20:11

Zerkey


1 Answers

Add the following tag to your web.config:

<configuration>
    <system.web>
       <trust level="Full" />
    </system.web>
</configuration>

The servers on your hosting service is probably setup with a medium trust level. The 'PayPalCoreSDK' is requires your application to run with a full trust level.

like image 172
Mark Smith Avatar answered Oct 18 '22 14:10

Mark Smith