I'm new to .NET and having a difficult time deciphering when to use namespaces and where to place "using" clauses. For this one project, I'm trying to develop a .NET page within a web application that has 99% of the pages written in Classic ASP. I started by creating a C# website in MS Visual Web Developer 2010 Express. Within that website, I created a web form. So far, so good. To add to the confusion, let's inject another unfamiliar concept to the mix - a web service - 2 of them to be exact. Let's call them navCustomer and navShipTo. The name of the website is Registration, so I guess that's the namespace - yes/no?
The first line of the web form aspx file, Default2.aspx, is:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Registration.Default2" %>
Here are the first few lines of Default2.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Mail;
using System.Net;
namespace Registration
{
using navCustomer;
using navShipTo;
public partial class Default2 : System.Web.UI.Page
{
..........
when I build and run it from within the Visual IDE, it runs great. When I try to open the code from the browser through normal website navigation, I get this error:
==============================================
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'navCustomer' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 14: namespace Registration
Line 15: {
Line 16: using navCustomer;
Line 17: using navShipTo;
Line 18:
==============================================
It ain't right, I tell ya'! Please help.