如何提供一个备用组件,而不是不能装入一个? [英] How to provide a fallback assembly instead of the one that can't be loaded?

查看:197
本文介绍了如何提供一个备用组件,而不是不能装入一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行时,如果引用的程序集加载失败与如强名称验证失败(因为它的测试签名),有没有办法从另一个路径提供了一个替代组件,它是真正的签名?

At runtime, if a referenced assembly fails to load with e.g. "Strong name validation failed" (because it's test-signed), is there a way to provide a substitution assembly from another path that is real-signed?

我想订阅AppDomain.CurrentDomain.AssemblyResolve,但它并没有被解雇,因为坏组装技术上存在,它只是不能被加载。

I tried subscribing to AppDomain.CurrentDomain.AssemblyResolve, but it doesn't get fired, because the "bad" assembly technically exists, it just can't be loaded.

有没有一种通用的方法来提供一个备用组件当一个组件无法加载?

Is there a generic way to provide a fallback assembly when an assembly can't be loaded?

推荐答案

我觉得你可以叫assembly.LoadFrom加载您所选择的组件,几乎无任何安全检查。摆在我们这个有很多在我们的应用程序,以便我们能够更好地处理与其他组件的版本变化的开始。

I think you can just call assembly.LoadFrom to load the assembly of your choice with practically no security checks. We us this a lot at the start of our app so we can better deal with other assemblies version change.

另外,也要看看 Assembly.LoadFrom方法(字符串,证据,字节[], AssemblyHashAlgorithm) 貌似可以控制传入散列以及散列算法。

Also look at Assembly.LoadFrom Method (String, Evidence, Byte[], AssemblyHashAlgorithm) looks like you can control passing in the hash as well as the hash algorithm.

这篇关于如何提供一个备用组件,而不是不能装入一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆