William
William

Reputation: 518

The type or namespace name 'Name' could not be found

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

I've spent the morning reading threads with the same error, but haven't found anything that seems to apply. The references seem to be set up correctly. I tried adding "using TestProject.Trivia.Web", but then I just get "The type or namespace name 'Web' does not exist in the namespace 'TestProject.Trivia' (are youmissing an assembly reference?).

In one project, I have this cs file:

using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace TestProject.Trivia
{
[DataContract]
public class Course
{
    [XmlAttribute, DataMember]
    public string Name { get; set; }

    [XmlAttribute, DataMember]
    public int Id { get; set; }

    [XmlElement, DataMember]
    public Question [] Questions { get; set; }
}

}

It has a reference to class TestProject.Trivia.Web, which has a javascript file with the definition of a question (which I'm referencing in the rest of the solution with no trouble).

Any ideas will be appreciated...

Upvotes: 0

Views: 1159

Answers (1)

YoryeNathan
YoryeNathan

Reputation: 14522

Defining Question is a javascript file does not create an object of Question in .Net, so you cannot use it as a .Net object in the C# code.

Make a class Question and use that.

public class Question
{
    ...
}

Upvotes: 2

Related Questions