找不到类型或名称空间 [英] The Type or namespace could not be found

查看:90
本文介绍了找不到类型或名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友


我有问题
我在根目录上创建了一个DBHelper文件夹.有两个用于连接字符串和数据访问的文件,例如1)dbHelper.cs和2)DatabaseHelper.cs.现在,当我在aspx文件中编写代码并尝试访问该类时,它不起作用.它给出类似
的错误
``如果您缺少using指令或程序集引用,则找不到类型或名称空间''

谁能告诉我如何给我的aspx.cs文件提供引用以访问DBhelper.cs和DatabaseHelper.cs中的所有类


谢谢大家...

Hello Friends


i have problem
i have make a folder DBHelper on root. there is two file for connection string and dataaccess like 1)dbHelper.cs and 2)DatabaseHelper.cs. now when i make a code in aspx file and try to access the class its not working. its give the error like

''the type or namespace cannot be found are you missing a using directive or an assembly reference''

can anyone tell me that how can i give the reference to my aspx.cs file to access all the class from DBhelper.cs and DatabaseHelper.cs


Thank You To all...

推荐答案

您需要在项目中添加dbhelper dll的引用.然后只有您可以访问它.
You need to add a reference of dbhelper dll to your project. Then only you can access it.


我认为两者都存在于不同的命名空间中.如果要调用该类,请同时使用命名空间.

例如.

I think both are there in different namespaces. If you want to call the class use the namespace as well.

For eg.

namespace My.Namespace
{
    public class MyClass
    {
        public void MyMethod()
        {
            My.Other.Namespace.MyotherClass obj=new My.Other.Namespace.MyotherClass();

            obj.mymethod();
        }
    }
}

namespace My.Other.Namespace
{
    public class MyOtherClass
    {
        private void mymethod()
{
}
    }
}



如果您正在使用Web应用程序,则使用以下命令:
将名称空间放在类文件中,例如:
Hi,
If you are working with web application then use this:
Put the namespace in your class-file like:
namespace WbAppName.DBHelper
{
    class clsTest 
    {
       //Code goes here
    }
}



在您的asp.cs文件中尝试以下操作:



Try this in your asp.cs file:

using System;
using WbAppName.DBHelper;
//here WbAppName will be your web application name
class
{
    clsTest obj=new clsTest();//Now you can access your class-file
}




--Amit




--Amit


这篇关于找不到类型或名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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