2013-11-27 13 views
7

セキュリティ上重要なメソッド 'System.Management.ManagementObjectSearcher..ctor(System.String)'にアクセスするための 'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()'が失敗しました。セキュリティ上重要なメソッドにアクセスするセキュリティトランスペアレントメソッドによる試みが失敗しました

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です。

この例外を回避するために使用できるグローバル設定はありますか?

答えて

12

は、あなたのweb.configファイルに次のタグを追加:あなたのホスティングサービスに

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

サーバは、おそらくメディアの信頼レベルの設定です。 'PayPalCoreSDK'は完全な信頼レベルでアプリケーションを実行する必要があります。

// added because of security transparency change in framework 4.0 
[assembly: SecurityRules(SecurityRuleSet.Level1)] 

これが私のために仕事をしたのassemblyinfo.csするためにこれを追加すること

+1

感謝を。信頼レベルは既にフルになっています。私はDLLに署名し、セキュリティに敏感なコードを調整し、再コンパイルすることでこの問題を解決しました。私はPayPal SDKがオープンソースであることを嬉しく思います。あるいは私はSOLでした! – Zerkey

+1

「セキュリティに敏感なコードを微調整した方法」を説明してください。私は今、この問題を抱えています。私のDLLは署名されており、信頼=完全であり、これは動作しません。 – antman1p

0

私は溶液中でいくつかのパッケージの上書きをNuGetパッケージを管理する場合、それが問題でしたメインWebサイトプロジェクトのSystem.Web.Mvcアセンブリバージョンバインディング4.0.0.0に戻してください(私は5.0をインストールしました)。 Mvc v4.0がインストールされ、GAC経由でアクセス可能であったため、変更に気付かなかった。戻って設定する

0

私はブラウンフィールドアプリケーションで、多くの参照プロジェクトをソリューションで使用していました。 1つのプロジェクトは4.6.1の代わりに.NET 4.0に設定されていましたが、それはそれかもしれないと思っていましたが、それは問題ではありませんでした。私は追加する必要がありました:

[assembly:AllowPartiallyTrustedCallers] 

の「セキュリティ上重要な」方法を含むプロジェクトでassembly.csファイルに、そして私もやった

using System.Security; 

を追加するまで、それは私と一緒に幸せではなかったですトリック。

ジョーイ

1

4.6.1フレームワークにwpftoolkit 3.5フレームワークをアップグレードした後、assemblyinfo.csで以下のセキュリティルールは、問題を解決する:応答のための

// added because of security transparency change in framework 4.0 
[assembly: SecurityRules(SecurityRuleSet.Level1)] 
関連する問題