ofern01
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(ByVa l 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.GetCurrentDirect ory()
UpdateProgramFiles()
ShowMsg("Loading Station Application ...")
Shell(m_cAppPath & "\safPOS.exe", AppWinStyle.NormalFocus)
Me.Close()
End Sub
This is the error
System.ObjectDisposedExcep tion was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'SafPosStart'."
Source="System.Windows.For ms"
ObjectName="SafPosStart"
StackTrace:
at System.Windows.Forms.Contr ol.CreateH andle()
at System.Windows.Forms.Form. CreateHand le()
at System.Windows.Forms.Contr ol.get_Han dle()
at System.Windows.Forms.Conta inerContro l.FocusAct iveControl Internal()
at System.Windows.Forms.Form. SetVisible Core(Boole an value)
at System.Windows.Forms.Contr ol.set_Vis ible(Boole an value)
at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoopInner (Int32 reason, ApplicationContext context)
at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoop(Int3 2 reason, ApplicationContext context)
at System.Windows.Forms.Appli cation.Run (Applicati onContext context)
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.OnRun( )
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.DoAppl icationMod el()
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.Run(St ring[] commandLine)
at safPOSStart.My.MyApplicati on.Main(St ring[] Args) in 17d14f5c-a337-4978-8281-53 493378c107 1.vb:line 81
at System.AppDomain.nExecuteA ssembly(As sembly assembly, String[] args)
at System.AppDomain.ExecuteAs sembly(Str ing assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.Hos tingProces s.HostProc .RunUsersA ssembly()
at System.Threading.ThreadHel per.Thread Start_Cont ext(Object state)
at System.Threading.Execution Context.Ru n(Executio nContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHel per.Thread Start()
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(ByVa
Dim llOk As Boolean = True
Dim oInfoRow As DataRow
Dim DSXmlDataTable As DataTable = New DataTable
Me.Show()
Me.Activate()
m_cAppPath = Directory.GetCurrentDirect
UpdateProgramFiles()
ShowMsg("Loading Station Application ...")
Shell(m_cAppPath & "\safPOS.exe", AppWinStyle.NormalFocus)
Me.Close()
End Sub
This is the error
System.ObjectDisposedExcep
Message="Cannot access a disposed object.\r\nObject name: 'SafPosStart'."
Source="System.Windows.For
ObjectName="SafPosStart"
StackTrace:
at System.Windows.Forms.Contr
at System.Windows.Forms.Form.
at System.Windows.Forms.Contr
at System.Windows.Forms.Conta
at System.Windows.Forms.Form.
at System.Windows.Forms.Contr
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at safPOSStart.My.MyApplicati
at System.AppDomain.nExecuteA
at System.AppDomain.ExecuteAs
at Microsoft.VisualStudio.Hos
at System.Threading.ThreadHel
at System.Threading.Execution
at System.Threading.ThreadHel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.