?
Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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