0

我已经查看了很多关于这个问题的问题,并且大多数问题是通过将应用程序目标从 Net 4.0 Client 更改为仅 Net 4.0 来解决的,我的已经是这样了,所以这不是问题。情况是我刚刚获得了 Json.Net,并创建了一个类 Customer 来使用它,如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CC
{
    public class Customer
    {
        private string location;

        public string Location
        {
            get { return location; }
            set { location = value; }
        }

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private int serviceTimeMin;

        public int ServiceTimeMin
        {
            get { return serviceTimeMin; }
            set { serviceTimeMin = value; }
        }

        public Customer()
        {
        }
    }
}

然后在我的页面代码隐藏中,我有以下代码:

protected void Button_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();
            customer.Location = txtCustomerAddress + ", " + txtCustomerCity + ", " + txtCustomerState + " " + txtCustomerZipcode;
            customer.Name = txtCustomerFirstName + " " + txtCustomerLastName;
            customer.ServiceTimeMin = 3;
            string json = JsonConvert.SerializeObject(customer);
         }

它在同一个命名空间中,并且已经检查过了,当我输入它时它没有错误,只是当我构建调试时,我得到以下信息:

CS0246: The type or namespace name 'Customer' could not be found (are you missing a using directive or an assembly reference?)

并且源指向该行:

Line 290:            Customer customer = new Customer();

我错过了什么?

编辑:只是想澄清一下,这都在同一个命名空间和同一个项目(程序集)中。

4

2 回答 2

1

代码隐藏也在CC命名空间中吗?否则,您需要添加using CC到文件的顶部。

我唯一能想到的另一件事是,如果Customer没有正确构建。是否有任何其他错误或警告?这可能是一个副作用错误。

于 2012-07-22T23:03:25.473 回答
0

您是否正在运行测试,是否启用了代码覆盖率?有时在这种情况下,您的项目 DLL 将不会更新。

于 2012-07-22T23:56:34.110 回答