0

I am using Visual Studio 2012 Pro and I created a ASP.NET Empty Web Application project. I added a Linq to SQL class called PALinq in my App_Code directory and I also added a class file (.cs) in the App_Code directory.

I set the Context Namespace and Entity Namespace of the DBML to "PADB". I then added the using directive Using PADB; to my class file.

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

using PADB;

namespace PA.App_Code.Comm
{
    public class MessageBuilder
    {
        public static string GetPlayerContext(string username, string password)
        {


            using (PALinqDataContext db = new PALinqDataContext())
            {
                Player player = db.Players.Where(p => p.Email == username).SingleOrDefault();

                if (player != null)
                {

                }
            }
        }
    }
}

I changed the Build action on the .cs file to "Compile" and now I get a The type or namespace name 'PADB' could not be found (are you missing a using directive or an assembly reference?).

This is targeting .NET 4.5, any ideas why it can't see the Linq namespace? I have done this same methodology on other ASP.NET websites before VS2012 and it always worked.

  • There are 3 questions here. Firstly, your question title is: `A namespace cannot directly contain members such as fields or methods?`. Then state another error of `The type or namespace name 'PADB' could not be found (are you missing a using directive or an assembly reference?)`. Then you go on to ask `any ideas why it can't see the Linq namespace?`. – Simon Whitehead Feb 08 '14 at 07:25
  • I apologize for the confusion. Let me see if I can better explain. I have always worked with website projects and now I am trying to get a web application project going instead. I add LINQ files like I described above but I can't seem to use the data context in any .cs files in App_Code. I just get the namespace missing issue. If I change the build action on the DBML from content to compile, I get an error that says "A namespace cannot directly contain members such as fields or methods". – user3277183 Feb 09 '14 at 07:14
  • Everything is in one project? – Gert Arnold Feb 09 '14 at 08:49

0 Answers0