2008-08-23 88 views
11

當我嘗試從網絡共享(映射到一個驅動器).NET程序集(boo.exe),它失敗,因爲它只是部分信任:運行「部分受信任的」 .NET從網絡共享組件

Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers. 
    at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) 
    at BooCommandLine..ctor() 
    at Program..ctor() 
    at ProgramModule.Main(String[] argv) 
The action that failed was: 
LinkDemand 
The assembly or AppDomain that failed was: 
boo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=32c39770e9a21a67 
The Zone of the assembly that failed was: 
Intranet 
The Url of the assembly that failed was: 
file:///H:/boo-svn/bin/boo.exe 

根據a blog post的說明,我向.NET配置添加了一個策略,完全信任所有使用file:///H:/*作爲其URL的程序集。我通過將URL file:///H:/boo-svn/bin/boo.exe輸入到.NET配置中的評估組裝工具並注意到boo.exe具有無限制權限(它在策略之前沒有)來驗證此問題。

即使有權限,boo.exe也不會運行。我仍然收到相同的錯誤信息。

我能做些什麼來調試這個問題?是否有另一種方法可以從網絡共享中運行「部分可信」程序集,而無需爲每個要運行的程序集更改某些內容?

回答

0

我想你想添加AllowPartiallyTrustedCallers屬性到你的程序集。該錯誤消息意味着某些調用到您的boo.exe程序集中的內容不完全受信任,並且boo.exe沒有允許它的此屬性。

2

看看'caspol.exe'程序(隨.NET運行時提供)。您將不得不在您嘗試運行該應用程序的機器上執行此操作。我無法'標記'和組裝(可能只是我)。但是,使用caspol併爲我的應用程序LocalIntranet_Zone設置適當的權限,修復了我的類似問題。

我聽說過(但還沒有嘗試過),.NET 3.5 sp1刪除了這個嚴格的安全要求(不允許.NET程序集默認駐留在共享中)。