Click here to Skip to main content
13,736,882 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
we are using switch in my code on onrowdatabound but it is working fine from source code but when i use with IIS then it show below error
"
Error: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
"

I try to increse size of w3wp.exe but system not allow to increse
it show
c:\windows\system32\inetsrv\’ is denied


What I have tried:

try
            {

                LinkButton lbSelect = (LinkButton)e.Row.FindControl("lbtnUOM");
                string stri = Request["ShowDetails"];

                switch (stri)
                {

                    //PRODUCTION PLANNING
                    case "PRNumber": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "ProductionPPCNo": lbSelect.Attributes.Add("onclick", "return HelpVendorCode('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "','" + e.Row.Cells[1].Text.ToString() + "', '" + hdnID2.Value + "')");
                        break;
                    case "ProductionCustomer": lbSelect.Attributes.Add("onclick", "return HelpVendorCode('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "','" + e.Row.Cells[1].Text.ToString() + "', '" + hdnID2.Value + "')");
                        break;
                    case "ProductionFromSo": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "ProductionToSo": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "STATranNo": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;

                    case "STAUserId": lbSelect.Attributes.Add("onclick", "return HelpRemarkGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "','" + e.Row.Cells[1].Text.ToString().Trim() + "','" + hdnID2.Value + "')");
                        break;

                    case "SPNo": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "GroupCodeList": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "SPItemCodeList": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "SPCustomerCode": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "CustomerGroup": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "ItemDiscount": lbSelect.Attributes.Add("onclick", "return HelpWhGrid('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "CustomerCodeReciept": lbSelect.Attributes.Add("onclick", "return HelpCostCenterWindow('" + lbSelect.Text.Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "RECIEPT_PROCESS": lbSelect.Attributes.Add("onclick", "return HelpWindowStockTransfer('" + lbSelect.Text.Trim().ToString().Trim() + "','" + hdnID2.Value + "')");
                        break;
                    case "NITDocCustomer": lbSelect.Attributes.Add("onclick", "return HelpTo_FromItem('" + lbSelect.Text.Trim().ToString().Trim() + "','" + hdnID.Value + "','" + e.Row.Cells[1].Text.ToString().Trim() + "','" + hdnID2.Value + "')");
                        break;
                    case "TR_FROM_RETURN_INVOICE_NO": lbSelect.Attributes.Add("onclick", "return HelpVendorCode('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;
                    case "TR_TO_RETURN_INVOICE_NO": lbSelect.Attributes.Add("onclick", "return HelpVendorCode('" + lbSelect.Text.ToString().Trim() + "','" + hdnID.Value + "')");
                        break;

default:
                       throw new Exception(String.Format("Unknown state: {0}", stri));
                       break;
               }
           }
           catch (Exception ex)
           {
               this.RegisterStartupScript("AlertMsg", genUOM.strScr1 + ex.Message.Replace("'", "") + genUOM.strScr2);
           }
Posted 1-Jan-18 2:49am
Updated 1-Jan-18 3:41am
Comments
F-ES Sitecore 1-Jan-18 9:37am
   
What line does the error happen on? A stack overflow means your code is doing an infinite loop.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

A stack overflow means that something very wrong is happening: your code is directly or indirectly recursing and that has used the whole stack. How and where we cannot say from a trivial fragment of code.

So use the debugger: put a breakpoint on the lines
LinkButton lbSelect = (LinkButton)e.Row.FindControl("lbtnUOM");
and
this.RegisterStartupScript("AlertMsg", genUOM.strScr1 + ex.Message.Replace("'", "") + genUOM.strScr2);
and look at the exception detail (particularly the stack trace) when the overflow occurs. It should give you the method and line number that is causing the recursion.
  Permalink  
Comments
ArvindTomar 3-Jan-18 9:53am
   
i have checked but debugger not go to particular case it show the
Error on switch "an unhandled exception of type 'system.stackoverflowexception' occurred in mscorlib.dll"
OriginalGriff 3-Jan-18 10:02am
   
And what does the stack trace show you?
ArvindTomar 4-Jan-18 3:13am
   
I am using switch statement and around 700-800 cases in switch
how can i trace error in witch case have problem system show error on switch. it is working fine with source code but not working when i host site on IIS
OriginalGriff 4-Jan-18 3:44am
   
Add a try...catch block around the switch, and log the input value, the stack trace, and so forth. If you can't use the debugger, then you have to fall back on more traditional means of debugging - logging and post crash examination. You use the initial results of the try...catch to refine your logging until you narrow down the problem to specific code and / or input values.

Sorry, but we can't do that for you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 1 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100