The updater don't work: System.Reflection.TargetInvocationException

Sep 12, 2012 at 7:36 PM

I have a .NET 4 Winforms app. When running the updater get this:

 

System.Reflection.TargetInvocationException was unhandled
  HResult=-2146232828
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       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.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.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(Form mainForm)
       at TeleportCLI.Program.Main(String[] args) in c:\Proyectos\Server\TeleportCLI\Program.cs:line 85
       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: System.Threading.ThreadStateException
       HResult=-2146233056
       Message=ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
       Source=System.Windows.Forms
       StackTrace:
            at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
            at System.Windows.Forms.WebBrowser..ctor()
            at AppLimit.NetSparkle.NetSparkleForm.InitializeComponent()
            at AppLimit.NetSparkle.NetSparkleForm..ctor(NetSparkleAppCastItem item, Image appIcon, Icon windowIcon)
            at AppLimit.NetSparkle.Sparkle.ShowUpdateNeededUI(NetSparkleAppCastItem currentItem)
            at AppLimit.NetSparkle.Sparkle._worker_ProgressChanged(Object sender, ProgressChangedEventArgs e)
            at System.ComponentModel.BackgroundWorker.OnProgressChanged(ProgressChangedEventArgs e)
            at System.ComponentModel.BackgroundWorker.ProgressReporter(Object arg)
       InnerException: 

Running on Win7 64 Bits, VS 2012. Also the NetSparkleChecker.Net40.exe crash with

 

Nombre del evento de problema:	CLR20r3
  Firma del problema 01:	netsparklechecker.net40.exe
  Firma del problema 02:	1.0.83.0
  Firma del problema 03:	4e42fe73
  Firma del problema 04:	AppLimit.NetSparkle.Net40
  Firma del problema 05:	1.0.83.0
  Firma del problema 06:	4e42fe72
  Firma del problema 07:	47
  Firma del problema 08:	c
  Firma del problema 09:	System.Exception
  Versi�n del sistema operativo:	6.1.7601.2.1.0.256.1
  Id. de configuraci�n regional:	9226
  Informaci�n adicional 1:	0bda
  Informaci�n adicional 2:	0bda85d402fabda5e14f9d2e7848aadf
  Informaci�n adicional 3:	cff9
  Informaci�n adicional 4:	cff984982859a4bfe8362e55f67bfafc

Sep 12, 2012 at 8:05 PM

I found the solution, was related to:

 

http://stackoverflow.com/questions/1418466/single-threaded-apartment-cannot-instantiate-activex-control