2011-05-17 51 views
3

我試圖使用起來需要設置傳統的安全政策支持老.NET代碼:使用傳統的安全策略和動態操作一起在.NET 4

<NetFx40_LegacySecurityPolicy enabled="true" /> 

,並託管IronPython的(也許在某些地方使用dynamic關鍵字)。

我找不到同時使用它們的方法。如果我添加上述選項的app.config文件,我得到

動態操作只能 在同質的AppDomain執行的例外。

如果我不加這個選項,我得到

這種方法明確地使用CAS策略,已廢棄由.NET Framework。爲了兼容性原因啓用CAS策略,請使用NetFx40_LegacySecurityPolicy配置開關。有關更多信息,請參閱http://go.microsoft.com/fwlink/?LinkID=155570

有沒有辦法解決這個問題?

+0

我被困在同一塊岩石和堅硬的地方......你找到了解決方案嗎? ta – 2011-07-22 12:56:07

+0

不,我沒有,目前我正在使用傳統安全策略並避免使用任何動態操作。我們計劃在將來放棄需要此政策的圖書館... – vigoo 2011-07-27 15:50:06

+0

有沒有人有此修復? – caa 2014-08-15 11:31:34

回答

0

值得一提的是,不要設置LegacySerurityPolicy,並嘗試爲您的APP提供應用程序清單,而不是類似於以下內容。

<?xml version="1.0" encoding="utf-8"?> 
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <assemblyIdentity version="1.0.0.0" name="MyApplication.app" /> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> 
    <security> 
     <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> 
     <!-- UAC Manifest Options 
      If you want to change the Windows User Account Control level replace the 
      requestedExecutionLevel node with one of the following. 

     <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 
     <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 
     <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> 

      Specifying requestedExecutionLevel node will disable file and registry virtualization. 
      If you want to utilize File and Registry Virtualization for backward 
      compatibility then delete the requestedExecutionLevel node. 
     --> 
     <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 
     </requestedPrivileges> 
     <applicationRequestMinimum> 
     <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" /> 
     <defaultAssemblyRequest permissionSetReference="Custom" /> 
     </applicationRequestMinimum> 
    </security> 
    </trustInfo> 
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
     <!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.--> 
     <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node--> 
     <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>--> 
    </application> 
    </compatibility> 
    <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> 
    <!-- <dependency> 
    <dependentAssembly> 
     <assemblyIdentity 
      type="win32" 
      name="Microsoft.Windows.Common-Controls" 
      version="6.0.0.0" 
      processorArchitecture="*" 
      publicKeyToken="6595b64144ccf1df" 
      language="*" 
     /> 
    </dependentAssembly> 
    </dependency>--> 
</asmv1:assembly>