0

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).

0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

10 Comments

Are they in the same project? (Assembly)
Yes they are in the same project.
Hmm. Add that to your question. My answer is now irrelevant.
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.
Yeah, I checked all these things and I did mention that it's the same name space, I'll add that they're in the same project, thanks. Also, there are no other errors or warnings; in fact, visual studio doesn't say anything about the matter. I also think it's a build issue because it only displays when I build and view in browser; the error does not show up in the visual studio error list...
|
0

Are you running tests, and do you have code coverage enabled? Sometimes when this is the case your project DLL will not be updated.

1 Comment

I am debugging (pressing the green "play" triangle in visual studio 2010). I have not changed any defaults, so unless if that is enabled by default, then I do not have it enabled, where could I find that in Visual Studio? Never mind, i just looked it up and i am not doing that kind of testing, just simple debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.