Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:52:40+00:00 2026-06-16T09:52:40+00:00

I have a VB.NET 2010 Winforms application where I’d like to include line numbers

  • 0

I have a VB.NET 2010 Winforms application where I’d like to include line numbers in the stack trace. I’ve read the following question and answers:

how to print out line number during application run in VB.net

Which mentions “you always need to include the PDB file with your code, which contains debugging information that is used in situations like this”. Under advanced compiler settings I’ve tried “Generate debug info” as “pdb-only” and “full” for my release build and confirmed that a fresh PDB file is generated in the same directory as my EXE. However the following test code generates a line number of zero for each stack frame and doesn’t return a filename:

    Dim st As StackTrace = New StackTrace(ex)
    For Each sf As StackFrame In st.GetFrames
        MsgBox("Line " & sf.GetFileLineNumber() & sf.GetFileName)
    Next

However the following code straight after it generates an otherwise good looking stack trace so it doesn’t seem to be a problem with the exception handler in general:

ExceptionDetails.Text = ex.GetType.ToString & "(0x" & hr.ToString("X8") & "): " & ex.Message & vbCrLf & ex.StackTrace

I can’t seem to find any other likely settings under the project configuration and wondered if anyone had ideas on other things that may cause this problem. All the solutions I’ve found searching here and elsewhere just seem to suggest making sure the PDB is in the same path as the executable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:52:42+00:00Added an answer on June 16, 2026 at 9:52 am

    From the documentation of the constructor you’re calling:

    The StackTrace is created with the caller’s current thread, and does not contain file name, line number, or column information.

    Try using:

    Dim st As StackTrace = New StackTrace(ex, True)
    

    instead, which uses this constructor. The second constructor parameter is described as:

    true to capture the file name, line number, and column number; otherwise, false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have published a WinForms application from Visual Studio 2010. It uses .NET 4.0.
I have a C# 2010 WinForms application using .Net Framework 4. I am using
I have developed a WinForm Application with VB.Net (VS2010) having Office 2010 Professional Installed,
I have a WinForms app built with VB.Net in VS 2010, and I'm scratching
I have created a Visual Studio 2010 ASP.NET Web Application. With it I have
I have created a Visual Studio 2010 ASP.NET Web Application. I've noticed that if
I have a .NET WinForms application that I've converted into a COM dll using
I have created a WinForms application using C# 2010. It contains a report created
Our environment: Visual Studio 2010, c#, .net 4 client profile. We have a Winforms
I have a VB.NET 2010 application that loads data from SQL Server to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.