2
votes

I have a problem with a created unit-test. I have 2 projects. One is the "real" project the other one is the unit-test-project. After i click on a method in the real-project and select "create unit tests". Then I got the code for the unit-test in the testproject.

Now, after compiling i get the following error-message:

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

Then I added a public-key to the InternalsVisibleTo-Declaration in the AssemblyInfo.cs of the real-project. But now i get a compile-error for each class in the real-project which is internal and sealed. The message is:

'CLASSNAME' is inaccessible due to its protection level

What can I do to fix this? Any ideas?

2
Are your tests in the same namespace/assembly?PeskyGnat
No. The namespaces are different.Tomtom
the 'internal' specifier indicates that access is limited to the same assembly, so if your tests are in a different assembly, you'd likely see this errorPeskyGnat
A potential answer might be found in this question stackoverflow.com/questions/106907/…PeskyGnat
But therefore i added the InternalsVisibleTo-Declaration in the AsseblyInfo.cs of the real-project. The msdn says that this should work...Tomtom

2 Answers

1
votes

Put in the name of the assembly, then a comma and your PublicKey. Remember to remove any line breaks etc in your public key when you paste it in to your AssemblyInfo file

[assembly: InternalsVisibleTo("AssemblyName, PublicKey=xxx")]
0
votes

Yes I added the public-key-token. It looks like the following:

[assembly: InternalsVisibleTo("NAMESPACE, PublicKey=00240000048000009 40000000602000000240000525341310004000001000100354f0966de4a992baa1ed0f2 faf643f86fd2c74aee8b9dc6c0321f9d658166658ec154aaed70ab4b92a21a3c1e7e53 200232043c0d0b791496fd0201d21f18433ee9507022f2a72829d1dd32b106f86c68e 620d2a39f02f3a8b82aa23196ef7f7f4880020dd340dd2dfecdd1b3051b1e659c9e18c 8e21cc90bc33de306712b86")]