且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

命名空间中不存在!

更新时间:2023-02-20 11:31:19

确认

  • ConsoleApp 的项目有一个参考的 Foo.Common 项目(做的没有的浏览对于Foo.Common.dll),

  • The ConsoleApp project has a reference to the Foo.Common project (do not browse for Foo.Common.dll),

命名空间中不存在!

该文件包含使用指令,其中 CommonClass 声明的命名空间,

the file contains a using directive for the namespace in which CommonClass is declared, and

CommonClass 被声明为公开

所以,你的文件应该是这样的:

So your files should look like this:

CommonClass.cs 的中的 Foo.Common 的项目:

namespace Foo.Common
{
    public class CommonClass
    {
        public CommonClass()
        {
        }
    }
}


的Program.cs 的中的 ConsoleApp 的项目:


Program.cs in ConsoleApp project:

using Foo.Common;

namespace ConsoleApp
{
    public class Program
    {
        public static void Main()
        {
            CommonClass x = new CommonClass();
        }
    }
}