Search code examples
c#internalsvisibleto

InternalsVisibleTo does not work


I insert the line:

[assembly: InternalsVisibleTo("MyTests")]

inside my project under test( Properties/AssemblyInfo.cs) where MyTests is the name of the Unit Test project. But for some reason I still cannot access the internal methods from the unit test project.

Any ideas about what I am doing wrong ?


Solution

  • If your assembly is signed with a strong name look at this answer.

    Otherwise check that the name of your test assembly really is "MyTests.dll" (it doesn't have to match the project name, though it will by default).