Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900