[英].net local assembly load failed with CAS policy
我們收到以下程序集加載錯誤。 程序集從本地路徑“ C:\\ Program Files \\ ASWorx Products \\ ASWorx \\ Bin \\”加載。 舊版本的二進制文件不存在問題。 當我們通過電子郵件發送了新的二進制文件時,就會出現此問題。 構建設置不會更改。 我們如何解決這個問題? 該問題出現在Win7 32位計算機中
File name: 'file:///C:\Program Files\ASWorx Products\ASWorx\Bin\ASConnexDI.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)
at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at NeST.ICE.IOSystem.DIManager.InitializeDI()
我可以使用下面的鏈接並將設置添加到我的配置中來解決此問題。
https://msdn.microsoft.com/zh-CN/library/dd409252(VS.100).aspx
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
我不得不使用該方法
Assembly.UnsafeLoadFrom()
而不是Assembly.LoadFrom,它解決了我的問題...在以下鏈接中找到了它:
https://msdn.microsoft.com/zh-CN/library/dd409252(VS.100).aspx
除了以上給出的答案,這里是我針對該問題的解決方案。
嘗試執行解除阻止操作始終會導致文件似乎仍然被阻止。
因此,我創建了一個新文件夾,將其復制到受影響的文件上,然后逐個文件執行解鎖文件。 令人驚訝的是,與在原始文件位置中執行相同的操作相比,該標志被刪除了。 因此,最后一步是將現在已解除阻止的文件復制回原始位置。 做完了!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.