" does not exist in the namespace "". (do you miss the assembly reference?) I have a pr...">

CS0234: The type or namespace name "<namespace2>" does not exist in the namespace "<namespace1>". (do you miss the assembly reference?)

I have a project that gets "Type or namespace" does not exist in the class or namespace error. I saw many solutions here, but I could not solve my problem.

I have a solution with two projects, Web.Frameworks.Database and Web.Reports.OrderReporting. I am trying to reference the Frameworks.Database project in Report.OrderReporting. I also confirmed that both projects are compiled into the same environment (.NET Framework 4.5) Updated: I already added a link to the project (in the Solution Explorer).

Currently, there is only one .cs file in the Frameworks.Database project, there are not many there, 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 a debugger (F5 in Visual Studio), everything will be fine. But if I create my solution, and then get access to 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 advice would be appreciated. I have read a lot of time on similar issues, unfortunately, without success. Thanks!

+6
source share
1 answer

I solved the problem.

The real problem is that my virtual directory in IIS did not point to the correct folder, so the page could not find the DLL (which was correctly specified in my project).

Earlier, I encountered the error "Parser Error Message: Could not load type" in this line:

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

But I thought I solved this problem by changing "CodeBehind" to "CodeFile" (as recommended in another thread on another site about the Parser Error Message). This was, unfortunately, a misleading review, as it simply forces you to compile code at run time instead of compile time.

I finally fixed the problem by starting in a new project / project with a small Hello World page, I encountered the Parser error again, and as soon as I fixed it correctly (setting my virtual directory), I could then reference DLLs and other projects.

Thanks to those who looked and commented - I appreciate your time.

+4
source

All Articles