尝试使用安全透明方法'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()'来访问安全关键方法'System.Management.ManagementObjectSearcher..ctor(System.String)'失败.
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.
Run Code Online (Sandbox Code Playgroud)
此stackoverflow答案提到将[SecuritySafeCritical]
属性添加到类中,但在这种情况下,正在播放的类位于通过NuGet加载的DLL中.
我可以使用任何全局设置来绕过此异常吗?
小智 14
将以下标记添加到web.config:
<configuration>
<system.web>
<trust level="Full" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
托管服务上的服务器可能设置为中等信任级别.'PayPalCoreSDK'要求您的应用程序以完全信任级别运行.
小智 7
将其添加到assemblyinfo.cs
// added because of security transparency change in framework 4.0
[assembly: SecurityRules(SecurityRuleSet.Level1)]
Run Code Online (Sandbox Code Playgroud)
这为我完成了这项工作....
归档时间: |
|
查看次数: |
15412 次 |
最近记录: |