Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4.0 application throws exception on a machine without Visual Studio

My application works great on all computers here that has Visual Studio installed, but it does not work on the machine that does not have Visual Studio.

The application just crashes on start up with this message in the Event Viewer:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException
Stack:
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[])
at IssueTrackingSystem.My.MyApplication.Main(System.String[])

I tested a simple application with just one button, same results.

Error

UPDATE:

New error

like image 360
Ezi Avatar asked Jul 13 '26 21:07

Ezi


1 Answers

You need to get the exception's InnerException to really know what is going wrong. Project + Properties, Application tab, click the View Application Events button. In the upper left combobox above the editor window select "(MyApplication Events)", in the right combobox select "Startup".

That adds the Startup event handler. Make it look similar to this:

    Private Sub MyApplication_Startup(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf KaboomHandler
    End Sub

    Private Sub KaboomHandler(sender As Object, e As UnhandledExceptionEventArgs)
        MsgBox(e.ExceptionObject.ToString())
        Environment.Exit(1)
    End Sub

You'll now get a stack trace that includes the inner exception. That should be good enough to find the static constructor that bombs. Post the stack trace you see in your question if that doesn't help.

like image 188
Hans Passant Avatar answered Jul 15 '26 10:07

Hans Passant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!