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() { }
    }
}
有帮助吗?

解决方案

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")]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top