【问题标题】:asp.net - web app vs web site - code behindasp.net - Web 应用程序与网站 - 代码背后
【发布时间】:2013-01-02 19:54:35
【问题描述】:

我有一个不久前建立的 asp.net 网站。我已经完成了使用 Visual Studio 将其转换为 Web 应用程序的过程。现在我已经转换了它,我在使用添加到项目中的类库中的类时遇到了一些问题。后面的代码略有不同(如下)。谁能给我一个解决方案的建议。

--澄清一点 我有 3 个视觉工作室项目

1 类库(数据访问层) 1个类库(业务逻辑层) 1 个网站(表示层)-> 我将其转换为 Web 应用程序项目。与此类似的过程 (here)

我在业务逻辑层中有一个静态方法,我无法再从表示层后面的代码访问它。

---- 网站 -- /Profile/Default.aspx

using MyBusinessLogic;
public partial class Profile_Default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        MyBusinessLogic.Profiles.GetUserInfo(UserName);
    }
}

---- Web 应用程序 -- /Profile/Default.aspx

using MyBusinessLogic;
namespace WebApplication1.Profile
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MyBusinessLogic.Profiles.GetUserInfo(UserName); <---ERROR "can not access method on namespace"----------------------
        }
    }
}

【问题讨论】:

  • Now that I have it converted I am having some trouble using classes from a class library that is added to the project ... 什么?
  • 配置文件在 Web 应用程序中的开箱即用不像在网站项目中那样工作。
  • 我不确定我是否理解。你遇到什么麻烦了?具体来说,您期望什么行为以及究竟发生了什么不同?
  • 抱歉给您带来了困惑。我没有使用内置的 asp.net 配置文件。我在数据库中进行自己的配置文件管理。我的网站项目有一个添加到项目中的库。它用于业务逻辑层。我无法从添加的业务逻辑层访问类。
  • 这不就是在你的类所在的命名空间中添加 using 语句的简单例子吗?

标签: asp.net code-behind


【解决方案1】:

我在转换中遇到过类似的问题。请检查类似的命名空间 (Mybusinesslogic.Profiles) 如果你有 resharper,只需编写 profile.getuserinfo 并检查它是否解析为正确的业务逻辑程序集,或者当前命名空间中存在另一个重复项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 2010-10-05
    • 2011-02-03
    • 2010-09-10
    • 2010-09-25
    • 1970-01-01
    • 2014-05-02
    相关资源
    最近更新 更多