arame3333
arame3333

Reputation: 10193

ASP.Net: The type or namespace name 'namespace ' could not be found (are you missing a using directive or an assembly reference?

This should be an easy fix. I created a Linq to SQL class using SQLMetal. I added it to my project and put it in the App_Code folder. See below Yet intellisence is not picking up the namespace in my Default.aspx.cs code. See below. So when I build I naturally get an error as above. What should I do to fix this bug?

The generated Linq to SQL class in the App_Code folder begins as;

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace RiskManNew
{
        using System.Data.Linq;
        using System.Data.Linq.Mapping;
        using System.Data;
        using System.Collections.Generic;
        using System.Reflection;
        using System.Linq;
        using System.Linq.Expressions;
        using System.ComponentModel;
        using System;


        public partial class RiskManNew : System.Data.Linq.DataContext
        {
...
------------------------------------------------------------------------

The Default.aspx.cs begins as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using RiskManNew;
...

Intellisense does not recognise RiskManNew

Upvotes: 1

Views: 2648

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499770

I suspect the problem may be that you've got a namespace called RiskManNew and a class called RiskManNew. It's possible to work around this, but it's not worth the hassle. Just change one of the names.

If that's not the problem, it may be due to App_Code not being picked up properly. I've certainly seen that happen before - but it will be easier to diagnose once you've fixed the naming issue.

Upvotes: 1

Related Questions