Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare a friend assembly?

People also ask

How can I produce an assembly?

There are several ways to create assemblies. You can use development tools, such as Visual Studio, that can create . dll or .exe files. You can use tools in the Windows SDK to create assemblies with modules from other development environments.

How do I find my public key for Internalsvisibleto?

In the "Solution explorer" click on your project assembly name, and then head to "Tools > Get PublicKey".

Does C# have friend classes?

Bookmark this question.

Which one of the following is a type of member that can be accessed by any code in the same assembly but not from another assembly?

internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.


You need to sign both assemblies, because effectively both assemblies reference each other.

You have to put the public key in the InternalsVisibleTo attribute. For example, in Protocol Buffers I use:

[assembly:InternalsVisibleTo("Google.ProtocolBuffers.Test,PublicKey="+
"00240000048000009400000006020000002400005253413100040000010001008179f2dd31a648"+
"2a2359dbe33e53701167a888e7c369a9ae3210b64f93861d8a7d286447e58bc167e3d99483beda"+
"72f738140072bb69990bc4f98a21365de2c105e848974a3d210e938b0a56103c0662901efd6b78"+
"0ee6dbe977923d46a8fda18fb25c65dd73b149a5cd9f3100668b56649932dadd8cf5be52eb1dce"+
"ad5cedbf")]

The public key is retrieved by running

sn -Tp path\to\test\assembly.dll

Alternatively, get it from the .snk file:

sn -p MyStrongnameKey.snk public.pk
sn -tp public.pk