2012-03-20 23 views
2

.NET에서 응용 프로그램이 완전히 신뢰되는지 여부를 어떻게 테스트합니까?.NET 응용 프로그램이 완전 신뢰로 실행되고 있는지 테스트

내 응용 프로그램이 .NET 2.0에서 실행 중이며 해당 프레임 워크로 작업해야합니다.

+2

http://msdn.microsoft.com/en-us/library/0d005ted.aspx –

+0

당신은 단순히 응용 프로그램이 완전 신뢰에서 실행되고 있는지 여부를 테스트 할 또는 실행을 방지 싶은가 제한된 허가 부여가있는 경우 전혀? –

답변

3

유망 해 보이는 블로그 Finding out the current trust level in 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. 
관련 문제