Reputation: 753
I've looked at many questions about this issue and most fixed by changing the applications target from Net 4.0 Client to just Net 4.0, mine is already like that, so that is not the issue. The situation is I just got Json.Net and I created a class, Customer, to use with it, the following:
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()
{
}
}
}
and then within my pages codebehind I have the following code:
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);
}
It is in the same namespace and all, already checked that, and when I type it out it has no error, it's just when I build to debug that I get the following:
CS0246: The type or namespace name 'Customer' could not be found (are you missing a using directive or an assembly reference?)
and the source points to the line:
Line 290: Customer customer = new Customer();
What am I missing?
EDIT: Just want to clarify, this is all in the same namespace and same project (assembly).
Upvotes: 0
Views: 638
Reputation: 429
Are you running tests, and do you have code coverage enabled? Sometimes when this is the case your project DLL will not be updated.
Upvotes: 0
Reputation: 137438
Is the codebehind also in the CC
namespace? Otherwise you need to add using CC
to the top of the file.
The only other thing I can think of is, if Customer
did not build correctly. Are there any other errors or warnings? This may be a side-effect error.
Upvotes: 1