Solved

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

Posted on 2006-06-14
1
261 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
[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
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 16908174
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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