c# - 事件日志有错误。 "An unhandled exception has occurred"

标签 c# asp.net event-log

我正在使用 Visual Studio 2005 和 IIS 6.0.. 我在事件日志中有这个警告。我试图找到它是什么。我工作时从未经历过这个异常(exception)。 可以做什么,在哪里可以做,不再得到异常警告。提前致谢!!

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 10/13/2010 3:20:26 PM 
Event time (UTC): 10/13/2010 7:20:26 PM 
Event ID: fba7eb72412b4383a4c94bfcfd5c81a1 
Event sequence: 708 
Event occurrence: 6 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/568802591/Root-1-129314697219905000 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\Inetpub\wwwroot\kjdfd.live\ 
    Machine name: VME1053 

Process information: 
    Process ID: 472 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: NullReferenceException 
    Exception message: Object reference not set to an instance of an object. 

Request information: 
    Request URL: https://www.kjdfd.com:443/UserTownPage.aspx?tid=0 
    Request path: /UserTownPage.aspx 
    User host address: 173.188.124.86 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 11 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: False 
    Stack trace:    at UserTownPage.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Custom event details: 

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

页面加载:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SearchType = CommonHelper.SearchInnerType.Distance;
            MakeActive(SearchType);
            LoadData(true);
        }
    }

private void MakeActive(CommonHelper.SearchInnerType sType)
    {
        DealsActive.Attributes.Remove("class");
        PopularActive.Attributes.Remove("class");
        DistanceActive.Attributes.Remove("class");
        AZActive.Attributes.Remove("class");
        switch (sType)
        {
            case CommonHelper.SearchInnerType.A_Z:
                AZActive.Attributes.Add("class", "current");
                break;
            case CommonHelper.SearchInnerType.Distance:
                DistanceActive.Attributes.Add("class", "current");
                break;
            case CommonHelper.SearchInnerType.Popular:
                PopularActive.Attributes.Add("class", "current");
                break;
            case CommonHelper.SearchInnerType.Deals:
                DealsActive.Attributes.Add("class", "current");
                break;
            default:
                AZActive.Attributes.Add("class", "current");
                break;
        }

    }



private void LoadData(bool isSetPageIndex)
    {
        if (Session["keyword"] != null && Session["city"] != null && Session["state"] != null
            && Session["zipcode"] != null && Session["radius"] != null && Session["category"] != null)
        {
            string keyword = Session["keyword"].ToString();
            string city = Session["city"].ToString();
            string state = Session["state"].ToString();
            string zipCode = Session["zipcode"].ToString();
            double radius = Convert.ToDouble(Session["radius"].ToString());
            int categoryID = Convert.ToInt32(Session["category"].ToString());
            if (isSetPageIndex) PageIndex = 1;
            DisplayRecords(keyword, city, state, zipCode, radius, categoryID, 1);
        }
    }

最佳答案

问题似乎是在 UserTownPage 类型的 Page_Load 方法中抛出了一个 NullReferenceException。根据所提供的信息无法确定更多。

您需要做的是调试该方法并准确查看出现空引用的位置。

关于c# - 事件日志有错误。 "An unhandled exception has occurred",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3969869/

相关文章:

c# - Windows 事件日志中的这个条目是什么意思?

c# - 如何从输出参数获取值,同时提供一个值作为输入?

javascript - 在 Razor 中下拉更改时添加 html

c# - 设置具有相同文本的多个标签

c# - EventLog.WriteEntry 高级信息

c# - 窗口服务事件 ID

c# - 在 C# 中, "is"关键字是否始终必须跟在一个类之后?

c# - GetMethod 重载返回 null

c# - Elasticsearch 查询第一次慢

asp.net - 奇怪的异常测试 EmailSender