Solved

Error using Startup event in vb.net application

Posted on 2011-09-23
4
916 Views
Last Modified: 2012-05-12
I have a simple application with one form that performs some simple tasks, but If I add the attached code my app doesn´t run in other machines without visual studio.
Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            If e.CommandLine(0).ToLower = "/silent" Then

                ' ... run your code from here ...

                e.Cancel = True ' Suppress the default Form and Exit the Application
            End If

            ' Otherwise the App starts as Normal with the Form specified as the "Startup object" in Project --> Properties!

        End Sub

    End Class


End Namespace

Open in new window

0
Comment
Question by:dimensionav
  • 2
4 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 36585715
Shouldn't this line
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup

Open in new window

be
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As StartupEventArgs)Handles Me.Startup

Open in new window

0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36586747
Use the "View Application Events" button in Project --> Properties and then change the two dropdowns across the top of the code editor to place the method stub for you.

Not sure why you'd be getting an error.  Specifically, what does the error say and what line does it point to?
0
 

Accepted Solution

by:
dimensionav earned 0 total points
ID: 36893928
I have updated the operating system of the other computer then the application Worked (I believe are .net framework patches).

What components of XP OS allow the execution of this code?
0
 

Author Closing Comment

by:dimensionav
ID: 37163644
Updating helped on this but I don´t know what are the specific updates that this application needs
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now