构建错误 - 签署程序集 - 参考文献已损坏 [英] Build errors - Sign Assemblies- References broken

查看:61
本文介绍了构建错误 - 签署程序集 - 参考文献已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题,



我最近在我的解决方案中签署了所有程序集。这包括使用SNK文件的C ++ / CLI和C#项目的混合。发布哪个,我注意到有关损坏的引用的奇怪错误。



示例错误,



类型XXX .YYY'在未引用的程序集中定义。您必须添加对程序集Interop.XXX,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = abcd1234的引用。



XXX引用添加到项目中这显示错误。我删除并重新添加它都是徒劳的。此外,有许多项目使用了XXX引用,我删除并重新添加了对XXX的所有其他引用。 XXX项目的配置类型属性设置为实用程序类型。 XXX碰巧驻留在引用项目的obj\Debug文件夹中。



任何形式的帮助都非常感谢。



谢谢,

DD

Here is my problem,

I recently signed all the assemblies in my solution. That included a mixture of C++/CLI and C# projects using SNK files. Post which, I am noticing strange errors regarding broken references.

Sample error,

The type XXX.YYY' is defined in an assembly that is not referenced. You must add a reference to assembly 'Interop.XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234'.

XXX reference is added to the project that is showing the error. I removed and re-added it all in vain. Also, there were many projects that used the XXX reference, I remove and re-added every other reference to XXX. XXX project is having its "Configuration Type" property set to "Utility" type. XXX happens to reside in the obj\Debug folder of the referencing project.

Any sort of help greatly appreciated.

Thanks,
DD

推荐答案

这是很平常的事情。您只需在项目中重做您的参考。使用Visual Studio,您可以删除违规引用并再次添加它们。



有针对此类事情的补救措施:通过项目添加引用。将构建有问题的程序集的所有项目放在同一个解决方案中,然后使用添加引用窗口的项目选项卡建立对它们的所有引用。在这种情况下,如果由于某种原因更改位置,强名称或影响程序集标识的某些其他程序集属性,则将自动放置引用中的更改。如果您使用Browse更改程序集(建议仅用于没有源代码的程序集)或将程序集放在GAC中(仅在您有充分理由这样做并且非常了解后果时才推荐),则不会发生这种情况。 。



背景

引用以文件名的形式放在MSBuild项目文件中,或者项目引用,对于签名的程序集,公钥令牌用作其标识的一部分(这是强命名的目的之一,为程序集提供唯一标识)。如果您在解决方案之外更改程序集(请参见上文),程序集的标识将更改,但您对此标识的引用不会更改。这就是你必须相应地修改引用的原因。


如果由于某种原因你没有使用Visual Studio,你可以用其他方式解决问题(类似或不)基于您对装配参考的理解。



-SA
This is a usual thing. You can simply redo your reference in your project. With Visual Studio, you can remove "offending" reference(s) and add it (them) again.

There is a remedy against such thing: add references by projects. Put all projects which build the assemblies in question in the same solution and then establish all references to them by using the tab "Projects" of the "Add Reference" window. In this case, if you, by some reason, change location, strong name, or some other assembly attribute affecting assembly identity, the changes in the reference will be put automatically. It won't happen if you change assemblies put using "Browse" (recommended to be used only with assemblies without source code) or put assemblies in GAC (recommended only if you have a good reason to do so and understand really well the consequences).

Background:
The references are put in the MSBuild project file in the form of file name, or project reference, and, for signed assemblies, the public key token is used as the part of it identity (this is one of the purposes of strong naming, to give an assembly a unique identity). If you change the assembly outside of your solution (please see above), the identity of the assembly is changed, but your reference to this identity is not. That's why you have to modify the reference accordingly.

If, by some reason, you are not using Visual Studio, you can resolve the problem in some other way (similar or not) based on your understanding of assembly references.

—SA


这篇关于构建错误 - 签署程序集 - 参考文献已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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