While generating unit tests in Visual Studio 2008, I came across this error when creating a unit test for a Strong named signed assembly
Error: Friend assembly reference 'AssemblyName' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.
To fix this error, the steps are as:
1. Create a strong name key for the TestProject using the Visual Studio Command prompt
:sn –k “TestProject.snk”
2. Add the strong name key to the TestProject and in the properties of the TestProject, sign the assembly with the strong name key file
3. Extract the public key from the “TestProject.snk” and export it a new file as
sn –p TestProject.snk PublicKey.snk
4. Get the public key from the “PublicKey.snk file using
sn –tp PublicKey.snk
5. Add the public key in the AssemblyInfo.cs file as
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TestProject1, PublicKey=0024000004800000940000000602000000240000525341310004000001000100274324f6df083237e787bcafcd35a1f9a746b018e7be3d3c47654aeed9d1efbf3ad0b47c00eaae26531b9b4965170680bc699fca7bb5f4eb87980fd12676d26aaaa84aa5f0c26f6187535dded0734a57fe5a88aeaee22997b021b7630676e53702d211fa47cb6c915b282e669c2f444c85e9e096fc0b222efa93e61751e20dba")]
This should resove the error.
Thursday, October 23, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment