0

在下面的代码片段中,GoodBye方法默认标记为内部。我在 AssemblyInfo.cs 文件中添加了以下行,以使此方法在所有其他程序集中可用。

[assembly: InternalsVisibleTo("ConsoleApplication2")]

该类仍然没有将 GoodBy 方法暴露给外部。谁能帮我解决这个问题。提前致谢!

namespace ConsoleApplication2
{
    public class Program
    {
        static void Main(string[] args) { }
        public void SayHi() { }
        internal void GoodBye() { }
    }
}
4

1 回答 1

3

InternalsVisibleToAttribute必须提供您希望能够查看内部方法的程序集的名称。

在您的示例中,您似乎在说: 的内部方法ConsoleApplication2ConsoleApplication2.

相反,您想说的是 The internal methods ConsoleApplication2are visible to SomeOtherLib,您会这样做:

[assembly: InternalsVisibleTo("SomeOtherLib")]
于 2013-09-02T10:41:37.840 回答