Link to home
Start Free TrialLog in
Avatar of ofern01
ofern01Flag for United States of America

asked on

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

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()
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial