无法使用Assembly.LoadFrom从HTTPS站点下载

时间:2009-04-27 14:54:20

标签: c# assemblies

无法在Assembly.LoadFrom中使用HTTPS路径。

也尝试使用TrustAllCertificatePolicy类,但它不起作用。

我已经使用来自客户端计算机的caspol对服务器进行了全信任。相同的URL适用于禁用ssl。它不适用于启用ssl。请帮忙。

例外是:

System.IO.FileLoadException: Security problem encountered when connecting to URL for 'https://ip/tasks/tasks.dll'. File name: 'https://ip/tasks/tasks.dll'    
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity,
     Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)    
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, 
    StackCrawlMark& stackMark, Boolean forIntrospection)    
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, 
    Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)    
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)    
    WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value 
    [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated 
    with assembly bind failure logging. To turn this feature off, remove the registry value 
    [HKLM\Software\Microsoft\Fusion!EnableLog]. 

1 个答案:

答案 0 :(得分:0)

代码访问安全性将阻止从http和https位置执行代码到正常(完全权限访问)。

您需要创建一个新的AppDomain(以及可能的远程/可序列化类型以跨越应用程序域边界),AppDomain中的CAS设置可以使用Internet权限集运行。这样可以避免下载的代码修改本地计算机。

如果您真的信任远程代码(以及能够或将能够修改它的每个人),您当然可以创建自定义权限集以允许更多访问。