hi,
i want to collect information about my asp.net worker process, so i wrote the code below :
Process p = Process.GetCurrentProcess();
foreach (System.Reflection.PropertyInfo prop in p.GetType().GetProperties())
{

Response.Write(prop.Name + "<br>" + prop.GetValue(p, null).ToString());

}
when i run the page i get the following error :
Process must exit before requested information can be determined. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Process must exit before requested information can be determined.

Source Error:


Line 22: {
Line 23:
Line 24: Response.Write(prop.Name + "<br>" + prop.GetValue(p, null).ToString());
Line 25:
Line 26: }

what is the reason for this error and what should i do to get what i want?
thanks inadvance
Serkan Şendur

Try this:

Process p = Process.GetCurrentProcess();
pType = p.GetType();
pArray = pType.GetProperties();
foreach (System.Reflection.PropertyInfo prop in pArray)
{
  Response.Write(prop.Name + "<br>" + prop.GetValue(p, null).ToString());
}

i tried your code, it generates the same error, test your code before posting please.
i found another solution to this problem using try catch blocks as follows :

 Process p = Process.GetCurrentProcess();
    DataTable dt = new DataTable();
    dt.Columns.Add("property");
    dt.Columns.Add("value");
    foreach (System.Reflection.PropertyInfo prop in p.GetType().GetProperties())
    {

        try
        {
            dt.Rows.Add(new object[] { prop.Name, prop.GetValue(p, null).ToString() });

        }
        catch
        {
            dt.Rows.Add(new object[] { prop.Name, "boş" });
        }


    }
    GridView1.DataSource = dt;
    GridView1.DataBind();

When you ask for help, you are limited to what other people can do. I am unable to check code before I post. Be grateful for any help at all. Manners 101.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.