2008-11-07 68 views
2

如何找出實際導致以下錯誤的內容?該頁面與其他頁面相同,但出於某種原因,只有該頁面出現此錯誤。它也只發生在具有中等信任級別的ISP(GoDaddy)上,我無法設置斷點並嘗試捕獲它。如何跟蹤ASP.NET安全異常

Server Error in '/' Application. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

 
Stack Trace: 

[SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] 
    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0 
    System.Security.CodeAccessPermission.Demand() +59 
    System.IO.Path.GetTempPath() +54 
    hh.a(Int32 A_0, Boolean A_1, Boolean A_2) +20 
    jg.b(c A_0, UInt64 A_1) +234 
    ei.b(c A_0, UInt64 A_1) +18 
    jg.a(c A_0, UInt64 A_1, Boolean A_2) +61 

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

如果你有這個問題,或只是知道我如何修復或追蹤它,請添加您的答案。媒體的信任等級是ISP要求的。

回答

2

您是否嘗試過使用IIS的本地實例並將信任級別設置爲中等?這會幫助你更快地調試和嘗試一些東西。

(無論如何,這是一個很好的習慣,你想在一個儘可能接近生產的環境中進行測試,並且VS web服務器肯定有一些重要的差異,如果你不測試在IIS中也是如此。)

1

我不相信GoDaddy支持完全信任 - 儘管最近可能已經改變。該錯誤是由​​調用引起的,該調用需要EnvironmentPermission

之前的調用堆棧被混淆了,所以我的猜測是來自組件供應商。檢查更新或修復它們的部分信任,或者替換它。

+0

在那個頁面上有一個DevExpress組件,但我重新啓動了它,但錯誤未解決。我改變了web.config希望它會重新編譯。有沒有其他方法可以強制頁面在遠程主機上編譯?我的最後一個選擇是重新創建從未擁有該組件的頁面並查看會發生什麼 – 2008-11-07 22:37:59

+0

這應該會導致重新編譯。檢查你是不是也緩存頁面。如果沒有,那麼你可能仍然有錯誤,它不是那個組件。 – 2009-05-03 13:18:03

0

在混淆的非調試程序集中設置斷點很困難。它可能會導致你無處。

找出混淆組件嘗試訪問臨時路徑的原因。