Solved

How Can I have a program Loader that does not stays open

Posted on 2006-06-14
1
221 Views
Last Modified: 2011-09-20
VS 2005 VB
I have a program loader that I wrote to check for Updates on the main program. If any, It will Copy the new updates and then execute the main program and close it self. The Main Program will stay running as normal

The problem I have is that when I close the loader, I get an error. Here is my code for the loader.

    Private Sub safPOSStart_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim llOk As Boolean = True
        Dim oInfoRow As DataRow
        Dim DSXmlDataTable As DataTable = New DataTable
        Me.Show()
        Me.Activate()
        m_cAppPath = Directory.GetCurrentDirectory()
        UpdateProgramFiles()
        ShowMsg("Loading Station Application ...")
        Shell(m_cAppPath & "\safPOS.exe", AppWinStyle.NormalFocus)
        Me.Close()
    End Sub

This is the error
System.ObjectDisposedException was unhandled
  Message="Cannot access a disposed object.\r\nObject name: 'SafPosStart'."
  Source="System.Windows.Forms"
  ObjectName="SafPosStart"
  StackTrace:
       at System.Windows.Forms.Control.CreateHandle()
       at System.Windows.Forms.Form.CreateHandle()
       at System.Windows.Forms.Control.get_Handle()
       at System.Windows.Forms.ContainerControl.FocusActiveControlInternal()
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at safPOSStart.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
0
Comment
Question by:ofern01
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
For VB.Net 2005 use the new Shown() event instead of Load():

Public Class Form1

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        ' make sure the form is fully displayed...
        Me.Show()
        Application.DoEvents()

        ' simulated form loading code...
        System.Threading.Thread.Sleep(5000)

        ' close the form
        Me.Close()
    End Sub

End Class
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

11 Experts available now in Live!

Get 1:1 Help Now