首页 新闻 会员 周边

ashx如何调用其他类?

0
悬赏园豆:10 [待解决问题]

不引用命名空间嘛说要我需要引用。。。

public class Handler1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        mv.reviewDao.GetNum("abc");
        
        context.Response.Write("Hello World");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
    
}

编译错误

说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS0103: 当前上下文中不存在名称“mv”
源错误:

 
行 17:         context.Response.ContentType = "text/plain";
行 18: 
行 19:         mv.reviewDao.GetNum("abc");
行 20:         
行 21:         context.Response.Write("Hello World");

引用命名空间后就出错!说“找不到类型或命名空间名称。。”

<%@ WebHandler Language="C#" Class="mv.Handler1" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using mv;

/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{ 
    ……
}

编译错误

说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS0246: 找不到类型或命名空间名称“mv”(是否缺少 using 指令或程序集引用?)
源错误:

 
行 6:  using System.Web;
行 7:  using System.Data;
行 8:  using mv;
行 9:  
行 10: /// <summary>

(本地测试没问题的!)

Hesfctrl的主页 Hesfctrl | 初学一级 | 园豆:183
提问于:2012-08-31 10:36
< >
分享
所有回答(2)
0
<%@ WebHandler Language="C#" Class="mv.Handler1" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
namespace mv
{

/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{ 
    ……
}
}

 

你的外层没有加命名空间吧,试试这样

Jolan | 园豆:171 (初学一级) | 2012-08-31 13:12

加了命名空间就会提示说“未能加载。。”(上传后)

支持(0) 反对(0) Hesfctrl | 园豆:183 (初学一级) | 2012-08-31 13:22

@Hesfctrl: 不会吧

支持(0) 反对(0) Jolan | 园豆:171 (初学一级) | 2012-08-31 15:06
0

应该是缺了和命名空间和,MV这个东西定义的引用

度一 | 园豆:226 (菜鸟二级) | 2013-04-27 17:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册