Attempt by security transparent method \'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()\' to access security critical method \'System.Management.Management
After upgrading wpftoolkit 3.5 framework to 4.6.1 framework, the below Security rules in assemblyinfo.cs resolve the issue:
// added because of security transparency change in framework 4.0
[assembly: SecurityRules(SecurityRuleSet.Level1)]
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.
In my case it was an issue when I managed a NuGet packages in the solution some package overrides System.Web.Mvc assembly version binding in main web site project. Set back to 4.0.0.0 (I had 5.0 installed). I didn't change notice the change because Mvc v4.0 was installed and accessible via GAC. Set back
adding this to assemblyinfo.cs
// added because of security transparency change in framework 4.0
[assembly: SecurityRules(SecurityRuleSet.Level1)]
this did the job for me ....
I was working on a brownfield application with a lot of referenced projects in the solution. One project was set to .NET 4.0 instead of 4.6.1 and I thought that might be it, but that wasn't the issue. I had to add:
[assembly:AllowPartiallyTrustedCallers]
to the assembly.cs file in the project containing the "security critical" method, and it wasn't happy with me until I also added
using System.Security;
That did the trick.
Joey