如何访问GetGlobalResourceObject()

时间:2010-11-11 11:31:56

标签: c# namespaces

我是c#的新手。我有这个班......

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public class clsErrorMessages
{
    string _sErrors;
    public clsErrorMessages(string sErrorTextFileName)
    {
        _sErrors = (String)GetGlobalResourceObject("resource","FriendlyErrors.txt");

    }
}

编译器说the name 'GetGlobalResourceObject' does not exist in the current context

我是否需要添加其他using

1 个答案:

答案 0 :(得分:7)

GetGlobalResourceObject()方法是HttpContext类的静态成员。您需要对其进行限定:

_sErrors = (string) HttpContext.GetGlobalResourceObject("resource",
    "FriendlyErrors.txt");