アプリケーションが完全な信頼で実行されているかどうかを .NET からどのようにテストしますか?
私のアプリケーションは .NET 2.0 で実行されており、そのフレームワークで動作する必要があります。
アプリケーションが完全な信頼で実行されているかどうかを .NET からどのようにテストしますか?
私のアプリケーションは .NET 2.0 で実行されており、そのフレームワークで動作する必要があります。
有望に見えるasp.netの現在の信頼レベルを見つけるというブログがあるようです。ブログが消えた場合に備えて、ここにコードを貼り付けました。
// Here is a sample code that returns the current trust level, assuming this
// code (or the calling code up the stack), is not loaded from GAC:
AspNetHostingPermissionLevel GetCurrentTrustLevel() {
foreach (AspNetHostingPermissionLevel trustLevel in
new AspNetHostingPermissionLevel [] {
AspNetHostingPermissionLevel.Unrestricted,
AspNetHostingPermissionLevel.High,
AspNetHostingPermissionLevel.Medium,
AspNetHostingPermissionLevel.Low,
AspNetHostingPermissionLevel.Minimal
}) {
try {
new AspNetHostingPermission(trustLevel).Demand();
}
catch (System.Security.SecurityException ) {
continue;
}
return trustLevel;
}
return AspNetHostingPermissionLevel.None;
}
// The result can be cached in a static field
// for the duration of the app domain lifetime.