参考装配不强名称 [英] Reference to assembly without strong name

查看:185
本文介绍了参考装配不强名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来引用库没有强大的名字? 当我添加引用组件引用和重建解决方案,一切都很好,但是当我调用类从该组件解决方案,它并没有建立。

Is there a way to reference a library without a strong name? When I add a reference to the assembly in references and rebuild solution everything is fine, but when I call the class from this assembly solution it doesn't build.

输出表示,引用的程序集应该具有强名称。什么是最好的解决办法?强命名库不是preferable。

Output says that referenced assembly should have strong name. What is the best solution? Strong naming library is not preferable.

推荐答案

我觉得你这里的问题在于,组件您尝试添加从正在以强大的名字,但你试图向大会签署的参考引用未签名。具有强名称的程序集只能引用其他具有强名称的程序集。

I think the problem you have here is that the assembly you are trying to add the reference from is being signed with a strong name but the assembly you are trying to reference is not signed. A strong-named assembly can only reference other strong-named assemblies.

签要么你引用的组件或不签署任何引用它的组件。

Either sign the assembly you are referencing or don't sign the assembly that is referencing it.

为什么错误只出现在你实际调用类的原因是因为编译器将去掉在编译输出的参考,如果没有code实际调用引用的程序集。

The reason why the error only appears when you actually call the class is because the compiler will strip out the reference in the compiled output if there is no code actually invoking the referenced assembly.

如果这是你的的情况下确实不能的无论是添加强名称为一个被引用,或从一个做引用删除强名称(对不起啰嗦),那么你将不得不看看类结合,透过反射运行,然后通过一个共同的基础或接口访问它 - 不理想可言;或通过反射实际上更糟调用它,或者动态

If it's the case that you really can't either add a strong name to the one being referenced, or remove the strong name from the one doing the referencing (sorry long-winded) then you are going to have to look at binding the class at runtime via reflection and then accessing it via a common base or interface - not ideal at all; or even worse actually invoking it via reflection, or dynamic.

这篇关于参考装配不强名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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