Question

In below snippet, the method GoodBye is marked as internal by default. I have added below line in AssemblyInfo.cs file to make this method available in all other assembly.

[assembly: InternalsVisibleTo("ConsoleApplication2")]

Still the class not expsoses the GoodBy method to outside. Can anyone please help me to resolve this. Thanks in advance!

namespace ConsoleApplication2
{
    public class Program
    {
        static void Main(string[] args) { }
        public void SayHi() { }
        internal void GoodBye() { }
    }
}
Was it helpful?

Solution

The InternalsVisibleToAttribute must be provided with the name of the assembly you wish to be able to view your internal methods.

In your example, you appear to be saying: The internal methods of ConsoleApplication2 are visible to ConsoleApplication2.

What you instead want to be saying is The internal methods of ConsoleApplication2 are visible to SomeOtherLib, which you would do like so:

[assembly: InternalsVisibleTo("SomeOtherLib")]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top