CS0234: The type or namespace name '<namespace2>' does not exist in the namespace '<namespace1>.' (are you missing an assembly reference?)

17,584

I have resolved the issue.

The real problem is that my virtual directory in IIS was not pointing to the correct folder, so the page couldn't find the dlls (that were properly referenced in my project).

I had earlier encountered a "Parser Error Message: Could not load type" error, on this line:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Orders.aspx.cs" Inherits="Web.Reports.OrderReports.Orders" %>

But I thought I had solved that issue by changing the "CodeBehind" to "CodeFile" (as recommended in another thread on another site about the Parser Error Message). That was, unfortunately, a misleading tip, as that just makes the code compile at runtime instead of compile time.

I finally fixed the problem by starting over in a brand new solution/project with a little 'Hello World' page, encountered the Parser Error again, and once I fixed it properly (by fixing my Virtual Directory), I could then reference dlls and other projects.

Thank you to those who viewed and commented - I appreciate your time.

Share:
17,584
Admin
Author by

Admin

Updated on June 15, 2022

Comments

  • Admin
    Admin almost 2 years

    I have a project that is receiving the "The type or namespace '' does not exist in the class or namespace ''" error. I've seen a lot of solutions here but I haven't been able to solve my problem.

    I have a solution with 2 projects, Web.Frameworks.Database and Web.Reports.OrderReporting. I am trying to reference the Frameworks.Database project in the Reports.OrderReporting. I have also confirmed both projects are compiling to the same framework (.NET Framework 4.5) Updated: I have already added a reference to the project (in the Solution explorer).

    At this time, there is only one .cs file in the Frameworks.Database project, there's not much in it, it looks like this:

    using System;
    using System.Data;
    using System.Web;
    using System.Data.SqlClient;
    
    
    namespace Web.Frameworks.Database
    {
        public class AccessDB : IHttpModule
        {
            /// <summary>
            /// You will need to configure this module in the Web.config file of your
            /// web and register it with IIS before being able to use it. For more information
            /// see the following link: http://go.microsoft.com/?linkid=8101007
            /// </summary>
            #region IHttpModule Members
    
            public void Dispose()
            {
                //clean-up code here.
            }
    
            public void Init(HttpApplication context)
            {
                // Below is an example of how you can handle LogRequest event and provide 
                // custom logging implementation for it
                context.LogRequest += new EventHandler(OnLogRequest);
            }
    
    
    
            public void OnLogRequest(Object source, EventArgs e)
            {
                //custom logging logic can go here
            }
    
            #endregion
    
            public string ConnectionString;
    
            public string DumbLittleMethod()
            {
                return "This is my oh so fancy string.";
            }...
    

    If I run this code through the debugger (F5 in Visual Studio), everything works fine. But if I build my solution, and then access the page through Internet Explorer, that is when I get the error - for Line 11.

    Line 9:  using System.Data;
    
    Line 10: using System.Data.SqlClient;
    
    Line 11: using Web.Frameworks.Database;
    
    Line 12: 
    

    Any advice or tips would be appreciated. I've already spent a lot of time reading through similar questions, unfortunately with no success. Thank you!