Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have trouble with building some projects. please consider this scenario:

i have 2 projects. for example A and B.
there is a reference from A to B
project of B was strongly signed (i did not want it to be signed for some reasons. so i decided to remove it`s checkbox of "sign the assembly")

there was a line of code in AssemblyInfo.cs file in the A project says:

[assembly: InternalsVisibleTo("B,publicKey=0024......")]

i changed it to:

[assembly: InternalsVisibleTo("B")]

now when i compile one of these projects, an error has came up and says:

Friend assembly reference 'B' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.

my question is here: how does compiler know that it was a signed assembly someday? and how can i completely remove strongly signed from assembly of B and finally build them correctly?

edited: by the way please note that both of theme is not strongly signed! because i remove both of those "sign the assembly" checkboxes from those project`s properties

when i changed the name of assembly to the some wrong name like "bla_bla_bla" that does not even exists, the error is the same!
[assembly: InternalsVisibleTo("bla_bla_bla")]
i think that this Theory is true:
in fact B Project does not compiled, and if it does not find the matched compiled project name (when building project A), compiler guess that B project is strongly signed with the public key that developer did not provide it! and at last it will prompt such odd error!
for the reason of B has a reference to A, when i compile B project, it will compile it's reference first (A project) and again compiler will prompt me that error (as the same as when i comopile project A)

but either it`s not true or some thing is wrong with my project A. because i start two new simple projects from scratch and every thing goes fine with no error (even when i change [assembly:...] statement to the invalid assembly name) i completely crashed
Posted
Comments
Herman<T>.Instance 9-Aug-11 10:16am    
what if you remove the reference and add it again?
BoxyBrown 9-Aug-11 11:05am    
You compile first A than B?

This is what MSDN has to say on this:

"If you use the C# compiler to compile the friend assembly, you must explicitly specify the name of the output file (.exe or .dll) by using the /out compiler option. This is required because the compiler has not yet generated the name for the assembly it is building at the time it is binding to external references. The /out compiler option is optional for the Visual Basic compiler, and the corresponding --out or –o compiler option should not be used when compiling friend assemblies with the F# compiler."
MSDN, InternalVisibleTo Attribute[^]
Does this help?

—MRB
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Aug-11 0:02am    
That's it, my 5.
--SA
reza assar 10-Aug-11 5:21am    
please attention! i have error when building AssemblyA (that AssemblyB has a reference to it) not AssemblyB (that has a reference from AssemblyA) i completely confused! assemblyA should not complaint about it. please read the answer carefully!
Oh My God! i have to remove this line of code:
C#
[assembly: AssemblyKeyName("")]

so that projectA completely forget about signing project and continue it`s easy life
as you know if the destination Assembly was signed so referenced assembly must be signed too. in fact this line of code remind compiler that this project is signed. so... the target assembly should be signed too. therefore compiler complaint about having friend assembly with no " , publicKey=..." token.
 
Share this answer
 
You need to specify the public key token. See this[^] article.

/ravi
 
Share this answer
 
Comments
reza assar 10-Aug-11 5:23am    
i do not want it to be signed brother! i unchecked signing check box of two projects... please read the answer carefully!

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



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