gpt4 book ai didi

c# - 尝试通过安全透明方法访问安全关键方法失败

转载 作者:太空狗 更新时间:2023-10-29 18:05:55 25 4
gpt4 key购买 nike

尝试通过安全透明方法“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.

This stackoverflow answer提到将 [SecuritySafeCritical] 属性添加到类中,但在这种情况下,起作用的类位于通过 NuGet 加载的 DLL 中。

我可以使用任何全局设置来绕过此异常吗?

最佳答案

将以下标记添加到您的 web.config 中:

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

您的托管服务上的服务器可能设置为中等信任级别。 “PayPalCoreSDK”要求您的应用程序以完全信任级别运行。

关于c# - 尝试通过安全透明方法访问安全关键方法失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20252500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com