C#: type or namespace name 'InternalsVisibleTo' could not be found

2020.12.26 | 87 words |

Overview

I’m trying to make it so my dotnet core test project can test the internals of my source project. To do that I’m using the InternalsVisibleTo attribute. However when I try to compile I’m getting the error:

error CS0246: The type or namespace name 'InternalsVisibleTo' could not be found

How do I fix this?

Solution

Typically errors like this mean you’re missing an import of some sort. I was able to fix this by adding this import line at the top of my file:

using System.Runtime.CompilerServices;

 

About the Ham

Hi I'm Hamilton - I built this! If you want more content like this subscribe to my email list, connect with me around the web, or take a look at some of my other projects.

More Projects

comments powered by Disqus