Solved

Error using Startup event in vb.net application

Posted on 2011-09-23
4
946 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

632 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