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 8481041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:27:28+00:00 2026-06-10T19:27:28+00:00

I am handling top level exceptions in the main entry point of a Windows

  • 0

I am handling top level exceptions in the main entry point of a Windows Form. I want to get access to the calling method/assembly which caused the exception in my handler. I have a feeling I will have to use the trace for this but I am not sure where.

Module Program
  Sub Main()
    Try
      AddHandler AppDomain.CurrentDomain.UnhandledException, Function(sender, e) ExceptionHandler.Handle(sender, DirectCast(e.ExceptionObject, Exception))
      AddHandler Application.ThreadException, Function(sender, e) ExceptionHandler.Handle(sender, e.Exception)
      Application.Run(ApplicationBase)
    Catch ex As Exception
      MessageBox.Show("Handled Exception")
    End Try
  End Sub
End Module

Public Class ApplicationBase
  Public Sub MethodA()
    'Causes an exception
    File.ReadAllLines("")
  End Sub
End Class

Public Class ExceptionHandler

  Public Shared Function Handle(sender As Object, e As Exception)
    Dim t As Type = sender.GetType()
    'Retrieve the calling method here?
    Dim callingMethod = "MethodA"
    Return True
  End Function

End Class

The object coming through as the sender is a thread, I was trying to see if this would be the assembly/object type which the call caused an exception.

My question is how do I get the method name/info and at a push the object name/assembly from within the “handle” method, if it is possible?

EDIT:

Although the e.ToString() will present method names – I am looking for access to the a list of methodinfo/the assemblies/the types to which the exception was caused like reflection and then I can get version numbers of .DLL’s etc. – I may be dreaming here but it’s something I would like to know if it is possible?

EDIT 2:

I tried e.TargetSite which for MethodA() exception returns the method info of File.ReadAllLines() I am looking for the Class method which causes the exception, so the method info would be MethodA – Although this is a lot closer than I would of thought I would get.

  • 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-10T19:27:29+00:00Added an answer on June 10, 2026 at 7:27 pm

    e.ToString() will return the full details including a stack trace. The stack trace includes all the method names.

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

Sidebar

Related Questions

Short form: How do you throw exceptions (or do nice, clean exception handling; or
Exception Handling in java based we services JAX-WS. I want to create user defined
I'm looking for some thin layer on top of handling HTTP requests that can
I've got a form that I'm handling with PHP. Before the user submits it,
I am using windows forms. I have a problem in handling mouse events. In
I find myself handling exceptions without specifying an exception type when I call code
I have the following piece of code for handling exceptions in my web application:
When writing GUI apps I use a top level class that controls or coordinates
While using the default validation handling in Silverlight ( using ValidatesOnExceptions=True,NotifyOnValidationError=True), you typically get
In my application I have a top level entity called Organization. The relationship between

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.