Share via


Problem with InternalsVisibleTo attibute for Friend assemblies

Question

Friday, August 25, 2006 10:50 PM

I want to use this to make a strong-named assembly's internals visible to my unit test assembly, but I am getting this error as soon as the unit test is compiled with code that accesses the internals:

Friend access was granted to 'Platform.Common.Tests.MBUnit, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F50572916E334B04400DB3A65217E76A09ED6049FF6853CAF564E00FAEE2C851841372D6536ADC933CB6DF7B244CBAA2F59B7CF23F8CFE0A232F3DCF5FB479CE5644654DDFF2E94EAA1F58603D4BDB47376A170BDB3E9AE2EA5B05D3CC64A7AAB03EB3D53DA5DFFE888D771E1F0387F8C0BA5ADBF0DD8CC3414FBD7B1E24C7E0', but the output assembly is named 'Platform.Common.Tests.MBUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'Platform.Common.Tests.MBUnit, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F50572916E334B04400DB3A65217E76A09ED6049FF6853CAF564E00FAEE2C851841372D6536ADC933CB6DF7B244CBAA2F59B7CF23F8CFE0A232F3DCF5FB479CE5644654DDFF2E94EAA1F58603D4BDB47376A170BDB3E9AE2EA5B05D3CC64A7AAB03EB3D53DA5DFFE888D771E1F0387F8C0BA5ADBF0DD8CC3414FBD7B1E24C7E0' or changing the output assembly name to match.

In the strong-named assembly, I have this attribute applied, according with MSDN docs.  The public key is definitely the one from the signing key used to strong-name the assembly:

[assembly: InternalsVisibleTo("Platform.Common.Tests.MBUnit, PublicKey=0024000004800000940000000602000000240000525341310004000001000100F50572916E334B04400DB3A65217E76A09ED6049FF6853CAF564E00FAEE2C851841372D6536ADC933CB6DF7B244CBAA2F59B7CF23F8CFE0A232F3DCF5FB479CE5644654DDFF2E94EAA1F58603D4BDB47376A170BDB3E9AE2EA5B05D3CC64A7AAB03EB3D53DA5DFFE888D771E1F0387F8C0BA5ADBF0DD8CC3414FBD7B1E24C7E0")]

Anyone have an idea what is the problem here?  Thanks

Riley

All replies (2)

Tuesday, October 17, 2006 4:25 PM âś…Answered | 2 votes

I got the same response and it took me awhile to figure it out.  Here are some steps to find the problem and fix it.

Go to your Tests project and open the Properties|Signing Tab.  Ensure that you have "Sign the Assembly" checked and the strong name key file referenced.

Save and compile the Project/Solution

 

This will fix your problem.


Wednesday, February 1, 2012 10:16 PM

Thanks a lot man.. It worked...