Asp.net Error Message Line Numbers
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About
C# Exception Stack Trace Line Numbers
Us Learn more about Stack Overflow the company Business Learn more about hiring c# get line number from exception without pdb developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the
How To Get Exception Line Number In C# In Release Mode
Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Display lines number in Stack Trace c# stack trace line numbers wrong for .NET assembly in Release mode up vote 94 down vote favorite 37 Is there a way to display the lines in the stack trace for the .NET assembly build/deployed in Release mode? UPDATE: My application is divided into three class library projects and one ASP.NET "website" project. The error I am trying to track down is in one of the three class library projects. I asp.net stack trace line numbers only deployed the pdb file for the class library project that is generating the "Object reference not set to an instance of an object" error. The line numbers are still not showing up in the stack trace. Do I need to deploy the pdb files for all projects to get the line numbers in the stack trace? Working solution Deploying the pdb file for each application fixed the line number issue. c# .net visual-studio stack-trace line-numbers share|improve this question edited Mar 30 '09 at 21:42 asked Mar 10 '09 at 0:44 Michael Kniskern 9,98750131198 add a comment| 8 Answers 8 active oldest votes up vote 87 down vote accepted Go into the Properties window for the project where you want to see stack trace line numbers. Click on the Build "vertical tab". Select "Release" configuration. Check the DEBUG constant parameter. Uncheck the "Optimize code" parameter to avoid the occasional trace issue with inlined code (this step is not essential). Press the Advanced... button and choose Output -> Debug Info -> pdb-only. Deploy the generated .pdb file with the assembly. share|improve this answer edited Mar 10 '09 at 2:15 RoadWarrior 13.6k1064114 answered Mar 10 '09 at 1:01
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Stack Trace Line Numbers Missing
About Us Learn more about Stack Overflow the company Business Learn more about c# stack trace missing line numbers hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
C# Stack Trace How To Read
Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up No line numbers in http://stackoverflow.com/questions/628565/display-lines-number-in-stack-trace-for-net-assembly-in-release-mode ASP.NET server errors up vote 2 down vote favorite 2 I'm using Visual Studio 2010 and C# ASP.NET. When I run my project using F5 key, it launches the ASP.NET Development Server, and that's the server I'm using for my work, not IIS. Problem is, when I get a "Server error in / application" unhandled exception error, the error page has no line numbers, nor http://stackoverflow.com/questions/9911783/no-line-numbers-in-asp-net-server-errors source file name. Just an error description and stack trace. For example: Server Error in '/' Application. DataField must be specified. [or whatever error message] 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: DataField must be specified. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [etc] I am compiling in Debug mode. My PDB is being generated in my project's BIN directory. In my project properties, under Web, NTLM authentication is turned off. In my web.config I have the following:
information from MSDN Visual Studio Achievements Latest Achievement: Loading Visual Studio Achievements Something went wrong getting the Visual Studio Achievements Follow us @ch9 Subscribe to https://channel9.msdn.com/Forums/TechOff/257195-Getting-line-number-in-Exception-for-ASPNET Channel 9 Sign In Channel9 Browse Tags Shows Series Blogs Authors Events Topics Coding4Fun Windows Azure Visual Studio DevOps Microsoft Mechanics MVPs Forums Coffeehouse Site Feedback Tech http://www.hanselman.com/blog/GettingTheLineNumberAndFileNameFromC.aspx Off Build Events WinHEC Visual Studio TechEd Build Microsoft Ignite Azure Speakers ForumsTechOff Getting line number in Exception forASP.NET Subscribe Oops, something didn't work. Try again? Sign In line number to subscribe to this conversation What does this mean? Subscriptions allow us send you email notifications when new content is added. You need to be signed in to Channel 9 to use this feature. Getting subscription Unsubscribe to this conversation Subscribe to this conversation What does this mean? Subscriptions allow us send you email notifications when stack trace line new content is added. Unsubscribing Subscribing Did you know you cansign up for email notifications? RSS reddit Tweet JParrish Aug 24, 2007 at9:04AM Hoping someone may have overcome this before.I use the enterprise library exception handling block to email myself any errors that occur within my ASP.NET application. At one time, I was getting the line numbers of the exceptions. I realize the performance hit but it is ok while I am testing deployment in new environments. Lately I have not been able to get the line numbers any more which makes the error too ambiguous. I have my build configurations to active debug, and in the web.config compilation debug is true.For libraries I call from the web app, I have the pdb files deployed into the bin folder. Does anyone know anything more I can check/do to try and get the exception to include the line number? I am using fixed name single page assemblies if that matters. ScanIAm This isan... Aug 24,
in C# are for __FILE__ and __LINE__. They watned to log the current file name and line number. Note that the "1" as the first parameter to the StackFrame constructor tells it to skip ONE frame up the stack, while the true tells it to capture the file and line info. [STAThread]static void Main(string[] args){ ReportError("Yay!");} static private void ReportError(string Message){ StackFrame CallStack = new StackFrame(1, true); Console.Write("Error: " + Message + ", File: " + CallStack.GetFileName() + ", Line: " + CallStack.GetFileLineNumber());}
«A Test of Google and Blogs: Selling my w... | Blog Home | Where's Juval Lowy?» About Scott Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author. About Newsletter Sponsored By Hosting By Comments [5] Share on: Twitter, Facebook, Google+ or use the Permalink Thursday, 18 September 2003 23:30:53 UTCThe only problem is this code only works in Debug builds. In a production Release build, the file name and line number information doesn't exist. Also, the StackFrame object may be null in a release build, which would NullReferenceException to be thrown at runtime.Sadly, the StackTrace/StackFrame approach isn't complete replacement for __LINE__ and __FILE__ for someone who needs to report this kind of information in a production Release build.Mike RizziFriday, 13 June 2003 14:09:03 UTCDoesn't this only work with assemblies containing Debug information? Also any thoughts on this in context of obfuscated assemblies?Brian NantzSaturday, 14 June 2003 06:07:42 UTCTrue. You're pretty much SOL from what I can tell when in Release or obfuscated. Brent Rector would know all about the obfuscation stuff. Perhaps the Enterprise Instrumentation Framework could step in for more robust tracing...Scott HanselmanSunday, 15 June 2003 22:41:49 UTCFrom the framework 1.0 documentationAshish DaveFriday, 19 September 2003 16:02:09 UTCtestScott Hanselman Comments are closed. Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. Blog Latest Greatest Hits Dev Tool List Podcast Hanselminutes This Developer's Life Ratchet & The Geek Speaking Speaking/Videos Presentations Tips Books ASP.NET 4.5 ASP.NET MVC 4 Relationship Hacks