如何解决“你错过了使用指令还是汇编引用?” [英] how to solve "are you missing a using directive or an assembly reference?"
本文介绍了如何解决“你错过了使用指令还是汇编引用?”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我得到的错误。我如何解决它?
'JEAN.BLL.BllRoom'不包含'getRoomDetails'的定义,也没有扩展方法'getRoomDetails'接受第一个参数类型'JEAN.BLL.BllRoom'可以找到(你错过了使用指令或汇编参考吗?)
this is the error i get. how do i solve it?
'JEAN.BLL.BllRoom' does not containt a definition for 'getRoomDetails' and no extension method 'getRoomDetails' accepting a first argument of type 'JEAN.BLL.BllRoom' could be found( are you missing a using directive or an assembly reference?)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using JEAN.DAL;
using JEAN.BLL;
namespace JEAN
{
public partial class ViewAvailableRoom : System.Web.UI.Page
{
BllRoom bll = new BllRoom();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
BindRoom();
}
private void BindRoom()
{
DALRoom myCat = new DALRoom();
DataSet ds;
ds = myCat.GetRoom();
gvRoom.DataSource = ds;
gvRoom.DataBind();
}
protected void btnNext_Click(object sender, EventArgs e)
{
Response.Redirect("PurchaseOrder.aspx");
}
protected void gvRoom_SelectedIndexChanged(object sender, EventArgs e)
{
string roomID = gvRoom.SelectedValue.ToString();
DataSet ds = bll.getRoomDetails(roomID);
dvRoom.DataSource = ds;
dvRoom.DataBind();
}
}
}
推荐答案
如错误所示,班级BllRoom
不包含名为getRoomDetails
的方法。
也没有扩展方法 [ ^ ]名为getRoomDetails
可以在BllRoom
类的实例上调用。
如果该方法不存在,则无法在对象上调用方法!
注意:不要忘记C#是区分大小写。你确定这个方法没有调用GetRoomDetails
,开头是大写的G吗?
As the error says, the classBllRoom
does not contain a method calledgetRoomDetails
.
There is also no extension method[^] calledgetRoomDetails
that can be called on an instance of theBllRoom
class.
You cannot call a method on an object if that method doesn't exist!
NB: Don't forget that C# is case-sensitive. Are you sure the method isn't calledGetRoomDetails
, with an upper-case "G" at the start?
添加程序集引用并使用类型的正确全名(通过使用
或不使用)。在解决方案资源管理器中选择参考项,然后查看上下文菜单。它将显示Add Reference ...。
您真的需要了解程序集并引用它们,以及名称空间和类型名称:
公共语言运行时的程序集 [ ^ ],
使用程序集进行编程 [ ^ ],
如何:确定程序集的完全限定名称 [ ^ ],
汇编位置 [ ^ ],
全局程序集缓存 [ ^ ],
命名空间(C#编程指南) [ ^ ],
MemberInfo.Name属性(System.Reflection) [ ^ ](我的意思是在这里使用System.Type.Name
),
Type.FullName属性(系统) [ ^ ]。
-SA
Add the assembly reference and use correct full names of the types (viausing
or not). Select an item "References" on the Solution Explorer and see the context menu. It will show "Add Reference…".
You really need to understand assemblies and referencing them, as well as namespaces and type names:
Assemblies in the Common Language Runtime[^],
Programming with Assemblies[^],
How to: Determine an Assembly's Fully Qualified Name[^],
Assembly Location[^],
Global Assembly Cache[^],
Namespaces (C# Programming Guide)[^],
MemberInfo.Name Property (System.Reflection)[^] (I mean the use ofSystem.Type.Name
here),
Type.FullName Property (System)[^].
—SA
这篇关于如何解决“你错过了使用指令还是汇编引用?”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文