【发布时间】:2016-10-29 10:36:36
【问题描述】:
我创建了类库,创建了Web Application项目,然后在Web Application项目as explained here中添加了对类库的引用,但不能为其添加“使用”。 (customer.cs 的命名空间也是“CDemoLib”) (当我添加“使用 CDemoLib;”时,我得到“无法解析符号 CDemoLib”
customer.cs的代码是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CDemoLib
{
public class Customer
{
private int _age;
private string _name;
public Customer()
{
Age = 0;
Name = "Not available";
}
public int Age
{
get { return _age; }
set { _age = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
【问题讨论】:
-
那么
Customer.cs中声明了什么命名空间,这似乎是CDemoLib中唯一的文件?使用指令是关于命名空间,而不是程序集。 -
课程是公开的吗?请向我们展示代码,而不是我们必须要求提供每一点信息。
-
不,看起来应该没问题。并且您能够毫无问题地添加参考?如果你扩大参考,你会看到什么?
-
那么究竟是什么报错呢?您是否尝试过禁用 Resharper 等插件?
-
老实说,我对它所不理解的细节了解得不够多,无法得出一个明智的答案。也许它不知道 .NET Core 或您正在使用的版本。
标签: c# reference asp.net-core using class-library