0

Just bumping this, no solution as yet...

I have a CRUD web app built in C# that updates a SQL Db. When I test it on my local machine it works fine, but when I upload to our intranet server it breaks, throwing up the error:

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

I have the namespace referenced in my backend file:

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

This is how I'm calling it:

//get user name from uName.cs 
uName obj = new uName();
string var = obj.ShowName();

uName.cs code:

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

/// <summary>
/// Summary description for uName
/// </summary>
namespace userName
{
    public class uName
    {
        public uName()
        {

        }  //constructor end   
        public string ShowName()
        {
           .......
        }

There are a number of methods following the constructor...

The userName namespace is held in the uName.cs file which is inside the App_Code folder.

I know this is a pretty common problem and I've done extensive research before posting the question...

I've tried the lots of solutions from SO but they don't fix the problem including:

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

The type or namespace name could not be found

Community
  • 1
  • 1
Kieran Quinn
  • 1,085
  • 2
  • 22
  • 49
  • 2
    i think ... if username is a class in App-Code Folder .... username is not a Namespace. – S.L. Aug 15 '14 at 12:27
  • also please post the uName.cs file ... else we can only guess where the Problem is – S.L. Aug 15 '14 at 12:28
  • 4
    You don't have a `using` directive for a *method* - you have it for a *namespace*, or maybe an alias for a specific type. – Jon Skeet Aug 15 '14 at 12:29
  • Posting code in question – Kieran Quinn Aug 15 '14 at 12:35
  • update your question please with the code ... it is unreadable as comment – S.L. Aug 15 '14 at 12:36
  • take a look at this http://stackoverflow.com/questions/1222281/classes-residing-in-app-code-is-not-accessible ... i guess you will find an answer here – S.L. Aug 15 '14 at 12:38
  • Did you also actually reference the project your `userName` is in? – Matthijs Aug 15 '14 at 12:43
  • @S.L. When I right click on the .cs file, I dont get a 'Build Action' property. Only options I get are 'File Name' and 'Full Path' – Kieran Quinn Aug 15 '14 at 12:54
  • @KieranQuinn ... Right-Click -> Properties and your properties pane of vs should open. The is a Property `Build Action` – S.L. Aug 15 '14 at 12:58
  • @S.L. Added screengrab. I dont get a Properties option but the properties pane is at the bottom, no option for Build Action – Kieran Quinn Aug 15 '14 at 13:03
  • 1
    Is there any reason for building as a Web Site project vs a Web Application project? May not have Build Action without being a Web Application, which you could convert to using the project right-click context menu. – Mike Guthrie Aug 15 '14 at 13:59
  • Converted to web app, changed setting to "Compile", built and uploaded to server. Still getting the error – Kieran Quinn Aug 18 '14 at 13:49
  • Is the uName.cs source part of the main project, or is it being built as a seperate assembly? If the latter, is the assembly that contains the `userName` namespace being deployed to the server? – Evil Dog Pie Aug 19 '14 at 09:44
  • It's part of the main project. Stored in App_Code folder – Kieran Quinn Aug 19 '14 at 10:41

0 Answers0