Kar*_*ren 6 .net c# namespaces .net-assembly
我有一个项目正在接收"类或命名空间''在类或命名空间中不存在''"错误.我在这里看到了很多解决方案,但我无法解决我的问题.
我有一个包含2个项目的解决方案,Web.Frameworks.Database和Web.Reports.OrderReporting.我试图在Reports.OrderReporting中引用Frameworks.Database项目.我还确认两个项目都在编译到同一个框架(.NET Framework 4.5)更新:我已经添加了对项目的引用(在Solution explorer中).
此时,Frameworks.Database项目中只有一个.cs文件,其中没有多少,它看起来像这样:
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.";
}...
Run Code Online (Sandbox Code Playgroud)
如果我通过调试器(Visual Studio中的F5)运行此代码,一切正常.但是,如果我构建我的解决方案,然后通过Internet Explorer访问该页面,那就是我收到错误 - 对于第11行.
Line 9: using System.Data;
Line 10: using System.Data.SqlClient;
Line 11: using Web.Frameworks.Database;
Line 12:
Run Code Online (Sandbox Code Playgroud)
任何建议或提示将不胜感激.我已经花了很多时间阅读类似的问题,遗憾的是没有成功.谢谢!
我已经解决了这个问题。
真正的问题是我在 IIS 中的虚拟目录没有指向正确的文件夹,因此页面找不到 dll(在我的项目中正确引用了它们)。
我之前遇到过一个"Parser Error Message: Could not load type"错误,在这一行:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Orders.aspx.cs" Inherits="Web.Reports.OrderReports.Orders" %>
Run Code Online (Sandbox Code Playgroud)
但我认为我已经通过将“CodeBehind”更改为“CodeFile”解决了该问题(正如另一个站点上有关解析器错误消息的另一个线程中所建议的那样)。不幸的是,这是一个误导性的提示,因为这只会使代码在运行时而不是编译时进行编译。
我最终通过在一个带有小“Hello World”页面的全新解决方案/项目中重新开始解决了问题,再次遇到了解析器错误,一旦我正确修复了它(通过修复我的虚拟目录),我就可以引用 dll 和其他的项目。
感谢那些观看和评论的人 - 我感谢您的宝贵时间。