ratooner 2016-05-17 15:28 采纳率: 0%
浏览 1397

httpcontext 类新增函数不能访问的问题

public sealed class HiContext
{
    public static HiContext Current
    {
        get
        {
            HttpContext current = HttpContext.Current;
            HiContext item = current.Items["ContextStore"] as HiContext;
            if (item == null)
            {
                if (current == null)
                {
                    throw new Exception("No HiContext exists in the Current Application. AutoCreate fails since HttpContext.Current is not accessible.");
                }
                item = new HiContext(current);
                HiContext.SaveContextToStore(item);
            }
            return item;
        }
            }
    private HiContext(HttpContext context)
    {
        this._httpContext = context;
        this.Initialize(new NameValueCollection(context.Request.QueryString), context.Request.Url, context.Request.RawUrl, this.GetSiteUrl());
    }
    public string a(int i)
    {......}
        public string b(int i)//新增
            {..........}

     }

    在另外一个类中调用 
             string a1=HiContext.Current.a(4); 正常
            而调用新增的b
              string b1=HiContext.Current.b(4); 错误

编译提示错误:
“xxxxx.xxxx.xxxx.HiContext”不包含“b”的定义,并且找不到可接受类型为“xxxxx.xxxx.xxxx.HiContext”的第一个参数的扩展方法“b”(是否缺少 using 指令或程序集引用?)

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-05-17 15:35
    关注

    看下你的命名空间下是不是有2个HiContext,你修改的和你调用的是一个HiContext类么?
    还可能是版本不同步重新编译下整个项目看看。

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿