Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I get some error in my asp.net application and .net frame work generate an error page

C#
Server Error in '/' Application.
Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.

Source Error:


Line 16:             if (!X.IsPostBack)
Line 17:             {
Line 18:                 Convert.ToInt32("");
Line 19:                 DepartmentRefresh();
Line 20:             }


Source File: f:\testproject\default.aspx
    Line: 18

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10896279
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +145
   System.Convert.ToInt32(String value) +43
   ERP.Areas.HumanResource.Views.ModuleReports.Report_DepartmentInformation.Page_Load(Object sender, EventArgs e) in f:\PROJECT\ERP\potassium\ERP_VS2013_MVC5\ERP\Areas\HumanResource\Views\ModuleReports\Report_DepartmentInformation.aspx.cs:18
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


I also want this details with my code ,bellow is my core

C#
public class BasePage : System.Web.UI.Page
    {

        protected override void OnInit(EventArgs e)
        {
            this.Page.Error += Page_Error;
            base.OnInit(e);
        }

        private void Page_Error(object sender, EventArgs e)
        {
            // Get last error from the server
            Exception exc = Server.GetLastError();
            sendErrorNotification(exc);


            
        }

        private void sendErrorNotification(Exception ex)
        {
            if (ex != null)
            {
                
                

            }
            //Server.ClearError();
        }
    }


please help.
Posted

Solution 2 by Mika Wendelius points to a very powerful tool.

At the same time, for most everyday chores, there is much simpler way: look at the exception property System.Exception.StackTrace:
http://msdn.microsoft.com/en-us/library/system.exception.stacktrace(v=vs.110).aspx[^].

This property is just as string; you cannot do much with it, but you will see all the exception information on the whole stack: all exceptions, file names and line numbers.

Another way is only available starting with C#.v5 and is limited to a single stack frame where you utilize the new "caller information" feature:
http://blogs.msdn.com/b/mvpawardprogram/archive/2012/03/26/introduction-of-new-features-in-c-5-0.aspx[^].

Look at Section 3, "Caller Information".

—SA
 
Share this answer
 
v2
Comments
KuntalBose 17-Jan-15 15:12pm    
I found a article
http://www.codeproject.com/Articles/726684/Help-Yourself-in-Debugging-Part-StackTrace-and-C
Sergey Alexandrovich Kryukov 17-Jan-15 15:25pm    
All right. The topic is very simple.
Will you accept other answers formally? I think these 3 ways make a comprehensive set of tools.
—SA
Wendelius 17-Jan-15 15:27pm    
Good point!
Sergey Alexandrovich Kryukov 17-Jan-15 15:30pm    
Thank you, Mika.
—SA
To get information about the exception source, you can use the StackTrace[^] class.

If I understood your question correctly, the example in the end of that documentation page is what you're after.
 
Share this answer
 
Comments
Thomas Daniels 17-Jan-15 9:32am    
+5
Wendelius 17-Jan-15 9:33am    
Thanks! I need to learn reading though :)
KuntalBose 17-Jan-15 10:05am    
I go through ,but don't understand the Frame.why they loop through the frame?
Wendelius 17-Jan-15 10:11am    
The frames describe the part of the program which is executed at the moment. Each call to another method adds a new frame to the stack. For example
- Your main loop is calling Method1 => new StackFrame added
- Method 1 is calling Method2 => new StackFrame added
At this point you would have two frames describing the point where the program is executing for each method.

KuntalBose 17-Jan-15 10:20am    
ok ,then how I determine exactly where the exception occurred.My goal is to get an error description like .net Framework ,which is describe my question.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900