I need to 'friend' a dll library that I didn't author.
I can see in the properties that it has a strong name, but how can I find out what the strong name is, so I can use it in System.Runtime.CompilerServices.InternalsVisibleTo
?
First, right click on the Assembly DLL -> Properties -> Details. Here you can find the name, version and Culture of your Assembly. It will give you the public key.
A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. It is generated from an assembly file using the corresponding private key.
To get the public key of a strong-named assembly, use the sn tool:
sn -Tp assembly.dll
This will show you the public key that you need to put in the InternalsVisibleTo
attribute. If you open a Visual Studio command prompt, the sn.exe tool will already be in the path.
However, I would question what you are trying to actually achieve. If you have a compiled assembly that you did not write, adding the InternalsVisibleTo
attribute to your code will let it access the internals of your code, but it wouldn't have compiled without already having friend access. If you are trying to access the internals of the other assembly, then the InternalsVisibleTo
attribute will need adding to the other assembly - something which you cannot do without recompiling it..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With