简体   繁体   English

找不到类型或命名空间“实用程序”

[英]Type or NameSpace "Utilities" could not be found

I have got error.我有错误。 Please help me out.请帮帮我。

The type or namespace name 'Utilities' could not be found (are you missing a using directive or an assembly reference?)找不到类型或命名空间名称“Utilities”(您是否缺少 using 指令或程序集引用?)

I have made a class with the namespace Utililties.我用命名空间 Utililties 创建了一个类。

namespace Utilities
{
    public class DatabaseManager
    {
        public string commandText;
        OdbcCommand cmd = new OdbcCommand();
        OdbcTransaction _tran = null;

        public DatabaseManager(String dbConn) {
            OdbcConnection  _conn = new OdbcConnection(dbConn);
            cmd = _conn.CreateCommand();
            _conn.Open();
        }

        public void setParameter(string name, OdbcType type, object value)
        {
            cmd.Parameters.Add(name, type).Value = value;
        }
    }
}

The class works fine but I also have the same problem when using in from another project.该类工作正常,但从另一个项目中使用时我也遇到了同样的问题。 I wonder what's happening and how to fix the problem.我想知道发生了什么以及如何解决问题。

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Data.Odbc;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using Utilities;     // This line have error highlighted in red color

You need to use using namespace directive to import the types in name space, The other project (website) where you are accessing class would have different namespace.您需要使用using namespace 指令来导入命名空间中的类型,您访问类的其他项目(网站)将具有不同的命名空间。 Make sure that you import by adding reference of the dll which has Utilities namespace.确保通过添加具有 Utilities 命名空间的 dll 的引用来导入。 The statement given below will import types in Utilities, if containing assembly is available.如果包含程序集可用,下面给出的语句将导入实用程序中的类型。

using Utilities;

Edit: If you have types in the namespace Utilities within website then you try putting them in app_code folder and build the website before you access them.编辑:如果您在网站内的命名空间实用程序中有类型,那么您可以尝试将它们放在 app_code 文件夹中并在访问它们之前构建网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM