0

Warning stored in Event Viewer from ASP NET application stopped IIS

Is not duplicate because I checked in my code if ns is populated without success, see this:

    if (!string.IsNullOrEmpty(str))
    {
        strArr = str.Split(splitchar);
    }

Please reopen this question, thank you.

I work in ASP NET 4.0 and C-sharp.

I have problem with this application because on the server in Event Viewer ( Application Events Records) is often stored this warning:

   at GridViewPage.RetrieveProducts() in d:\Inetpub\wwwroot\GV\GridViewPage.aspx.cs:line 69
   at GridViewPage.BindData() in d:\Inetpub\wwwroot\GV\GridViewPage.aspx.cs:line 225
   at GridViewPage.Page_Load(Object sender, EventArgs e) in d:\Inetpub\wwwroot\GV\GridViewPage.aspx.cs:line 30

In the code behind of GridViewPage.cs in the line 69 I have:

str = ns.ToString();

In the line 225:

gvProducts.DataSource = RetrieveProducts();

In the line 30:

BindData();

The problem is in :

private DataSet RetrieveProducts()

at the line where I have set

str = ns.ToString();

In the string ns I stored in List the values extracted from database because one user you could have more ratings.

Anybody know how can I resolve do this?

Can you help me?

Thank you in advance, my code below.

List<string> colorList = new List<string>();    

protected void Users()
{
    using (OdbcConnection cn =
        new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString))
    {
        string sql_aut = @" SELECT * FROM doTableUSers WHERE number = ?; ";

        using (OdbcCommand command =
            new OdbcCommand(sql_aut, cn))
        {
            try
            {
                if (Request.Cookies["number"] != null)
                {
                    command.Parameters.AddWithValue("param1", Server.UrlDecode(Request.Cookies["number"].Value));
                    command.Connection.Open();

                    using (OdbcDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                idColor = reader["idColor"].ToString();
                                colorList.Add(idColor.ToString());
                            }

                            ns = "";

                            foreach (string s in colorList)
                            {
                                if (ns.Length != 0)
                                {
                                    ns += ", ";
                                }
                                ns += s;
                            }
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Msg", "alert('User not stored.');", true);
                        }
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Msg", "alert('User not stored.');", true);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("operation failed!", ex);
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}


private DataSet RetrieveProducts()
{
    str = null;
    strArr = null;
    count = 0;

    str = ns.ToString();
    char[] splitchar = { ',' };

    if (!string.IsNullOrEmpty(str))
    {
        strArr = str.Split(splitchar);
    }

    for (count = 0; count <= strArr.Length - 1; count++)
    {
            sql = @" SELECT * FROM doTable WHERE idColor IN (?); ";
    }

    DataSet dsProducts = new DataSet();

    using (OdbcConnection cn =
      new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString))
    {
        cn.Open();

        using (OdbcCommand cmd = new OdbcCommand(sql, cn))
        {
            for (count = 0; count <= strArr.Length - 1; count++)
            {
                cmd.Parameters.AddWithValue("param1", Server.UrlDecode(strArr[count].Trim()));
            }

            OdbcDataAdapter adapter = new OdbcDataAdapter(cmd);
            adapter.Fill(dsProducts);
        }
    }

    return dsProducts;
}

Edit # 1

Complete event exception:

Event Type: Warning
Event Source:   ASP.NET 4.0.30319.0
Event Category: Web Event 
Event ID:   1309
Date:       24/07/2015
Time:       10.18.17
User:       N/A
Computer:   XXXXXXX
Description:
Event code: 3005 

Event message: An unhandled exception has occurred. 

Event time: 24/07/2015 10.18.17 

Event time (UTC): 24/07/2015 8.18.17 

Event ID: 71776aa8c7d747d5b00a5a84b2f7f701 

Event sequence: 6 

Event occurrence: 1 

Event detail code: 0 

Application information: 

Application domain: /LM/W3SVC/1/Root/GV/GridView-3-130821994960000000 

Trust level: Full 

Application Virtual Path: /GV/GridView 

Application Path: D:\Inetpub\wwwroot\GV\GridView\ 

Machine name: XXXXXXX 
 Process information: 

Process ID: 1932 

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.

at GridView.asp.RetrieveProducts() in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 69
   at GridView.asp.BindData() in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 225
   at GridView.asp.Page_Load(Object sender, EventArgs e) in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 30
   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)


Request information: 

Request URL: http://xxx/GV/GridView/GridView.aspx 

Request path: /GV/GridView/GridView.aspx 

User host address: 11.11.1.000 

User:  

Is authenticated: False 

Authentication Type:  

Thread account name: NT AUTHORITY\NETWORK SERVICE 


Thread information: 

Thread ID: 8 

Thread account name: NT AUTHORITY\NETWORK SERVICE 

Is impersonating: False 

Stack trace:    at GridView.asp.RetrieveProducts() in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 69
   at GridView.asp.BindData() in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 225
   at GridView.asp.Page_Load(Object sender, EventArgs e) in d:\Inetpub\wwwroot\GV\GridView\GridView.aspx.cs:line 30
   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.
Antonio Mailtraq
  • 1,331
  • 2
  • 27
  • 71

0 Answers0