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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:32:15+00:00 2026-06-12T06:32:15+00:00

I am creating a design pattern for non developers and I am incorporating a

  • 0

I am creating a design pattern for non developers and I am incorporating a catch all error handler with the UnhandledException event. I’d like to write the error out to a log file but the log file name has a time stamp in it, so it will change with each run. Is there a way my handler can receive or access the log file name string?

Thanks for any help

  • 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-12T06:32:16+00:00Added an answer on June 12, 2026 at 6:32 am

    Usually the UnhandledException event handler is located in the class that contains your startup code. So there is nothing to prevent you to define a shared public variable in this class that contains the name of your logfile. You could initialize its value at startup reading from a configuration file. Then inside the event is possible to use that variable to open your log file and write your information

    EDIT: in your scenario you could try this pseudocode

    Partial Friend Class MyApplication
    
        ' the name for the log file
        Public logName As String
    
        Private Sub MyApplication_UnhandledException(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
            Dim ex As Exception = e.Exception
            If Not ex Is Nothing Then
                MessageBox.Show(ex.Message)
                Using sw = new StreamWriter(My.MyApplication.logName)
                   .....
                End Using
            End If
        End Sub
    End Class
    

    and in your intial form add this call to define the logName

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        My.Application.logName = "C:\temp\text.txt"
        ' as test
        Throw New Exception("This is an unhandled exception")
    End Sub
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple application using the MVC design pattern where my model
I'm creating a WPF app using the MVVM design pattern, and I'm trying to
I decided to use the singleton design pattern while creating a view helper class.
I'm creating a WPF application using the MVVM design pattern that consists of a
I am looking for help with a design pattern for creating a database connection
After reading command design pattern, I have a question - Why we are creating
I'm thinking about creating some classes along a single-use design pattern, defined by the
We're creating a Interaction design pattern website for a class. We've been using google
I'm creating a WPF application using the MVVM design pattern, and I'm trying to
I'm creating a WPF TimeCard app using the MVVM design pattern, and I'm trying

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.