Automatic Updater NullReferenceException

Hi,

I have a multilanguage application and when I start it, the AutomaticUpdater Control works fine, but when I change interface language I have a NullReferenceException.

This is my language change code

Private Sub btnEnglish_Click(sender As System.Object, e As System.EventArgs) Handles btnEnglish.Click frmWait.Show() : frmWait.Refresh() : My.Settings.DefaultLanguage = "English" : My.Settings.Save() Dim frm As frmMain = LocalizedForm("en") : If frm Is Nothing Then Exit Sub btnLanguage.SmallImage = My.Resources.England_Small : frmWait.Dispose() Me.Close() : Me.Dispose() : frm.Show() End Sub

Private Function LocalizedForm(ByVal locale_name As String) As frmMain If Not Me.Created Then Return Nothing ' Stabilire cultura Dim culture_info As New CultureInfo(locale_name) ' Creare fire care folosesc aceasta cultura Threading.Thread.CurrentThread.CurrentUICulture = culture_info Threading.Thread.CurrentThread.CurrentCulture = culture_info shedMain.CalendarInfo.CultureInfo = culture_info calMain.CalendarInfo.CultureInfo = culture_info ' Reinitializare formular principal Dim frm As New frmMain : frm.Location = Me.Location : Return frm End Function

An here I attach the Stack trace

System.NullReferenceException was unhandled HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=AutomaticUpdater StackTrace: at wyDay.Controls.AutomaticUpdater.tmrWaitBeforeCheck_Tick(Object sender, EventArgs e) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 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 Psihosoft.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

Have you any solution for me? Thank you!

You're killing the form before the AutomaticUpdater finishes. Either use the AutomaticUpdater on a form that sticks around or use the AutomaticUpdaterBackend to process the updates.

Short answer: the AutomaticUpdater requires a form to be alive. You're killing it.

Thank you very much. I supposed this was the reason, but now I have the confirmation. I don't know how to use sticks around form or to change the language without reloading the main form. So, I will take into consideration the backend process. If you have time, please give me more info about the sticks around.... 🙂