【发布时间】:2014-03-28 08:57:13
【问题描述】:
我有一个项目收到“类或命名空间''中不存在类型或命名空间'”错误。我在这里看到了很多解决方案,但我无法解决我的问题。
我有一个包含 2 个项目的解决方案,即 Web.Frameworks.Database 和 Web.Reports.OrderReporting。 我正在尝试在 Reports.OrderReporting 中引用 Frameworks.Database 项目。 我还确认两个项目都编译到同一个框架(.NET Framework 4.5) 更新:我已经添加了对项目的引用(在解决方案资源管理器中)。
此时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.";
}...
如果我通过调试器(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:
任何建议或提示将不胜感激。我已经花了很多时间阅读类似的问题,不幸的是没有成功。谢谢!
【问题讨论】:
-
有时您可能需要手动为您的项目添加参考。在解决方案资源管理器下,右键单击您的项目,然后单击“添加引用”。将在 .Net 选项卡下打开一个窗口,搜索您的命名空间并添加它。我希望这能解决问题。
-
谢谢,汗,我已经这样做了(但在我原来的问题中没有提及)。
标签: c# .net namespaces .net-assembly