Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one use InternalVisibleTo without strong-named assembly in C#?

I could not find any clear statement on MSDN regarding this, there are some examples with strong names other are without, for me it seems like it should work even without but its not working.

Thank you

like image 238
CloudyMarble Avatar asked May 08 '12 06:05

CloudyMarble


People also ask

Why a strongly named assembly is required?

Reason. Based on the official site of VS, “Strongly-named” (or sometimes“strong-name”) is necessary for the assemblies to be accessed by other assemblies.

What's the usage of InternalsVisibleTo attribute?

The InternalsVisibleTo attribute is a well-known attribute for testing assemblies. The internal methods of an assembly become visible to the test project. This allows you to test the internal methods without using reflection, so your tests are more maintainable.

How do you verify strong name assembly?

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.

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".


1 Answers

The documentation is quite explicit:

Both the current assembly and the friend assembly must be unsigned, or both must be signed with a strong name. If they are signed with a strong name, the argument to the InternalsVisibleToAttribute constructor must include the full public key as well as the name of the assembly.

See this answer for an example of what full public key means.

like image 165
Frédéric Hamidi Avatar answered Oct 23 '22 23:10

Frédéric Hamidi