[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-06-14
1
Medium Priority
?
287 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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

834 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