从aspx.cs中的另一个类访问类成员 [英] Accessing class member from another class in aspx.cs

查看:71
本文介绍了从aspx.cs中的另一个类访问类成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net中的新蜜蜂。在asp.net应用程序中有一个名为DataAccessLayer.cs的
a类用于连接数据库。

在另一个页面中,即index.aspx,当我使用时......



I am a new bee in asp.net. In a asp.net application there is
a class named "DataAccessLayer.cs" use to connect database.
In another page i.e. index.aspx when i am using...

namespace WebApp 
{
    public partial class index : System.Web.UI.Page
    {
        DataAccessLayer objDataAccessLayer = new DataAccessLayer(); 
        
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}





它完全在我的localhost成功运行。但是当我托管它时会产生错误





it runs in my localhost success fully. but it generate error
when i am hosting it.

Error say: CS0246: The type or namespace name 'DataAccessLayer' could not be found (are you missing a using directive or an assembly reference?)





我的尝试:



我有另一个项目中的类库文件,在另一个解决方案中,我将类库和上面的项目一起添加。然后添加参考。但是一切都是徒劳的。



What I have tried:

I have make a class library file in another project and in another solution i add the class library and above project together. then add reference. but all are in vain.

推荐答案

按照MSDN的说明:编译器错误CS0246 [ ^ ]解决您的问题。
Follow the instruction from MSDN: Compiler Error CS0246[^] to resolve your issue.


这篇关于从aspx.cs中的另一个类访问类成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆