Exception has been thrown by the target of an invocation

Topics: CAB & Smart Client Software Factory
Jan 30, 2007 at 2:22 PM
I am getting this error when I try to run my application. I am using the Smart Client Solutions for lab4. I am trying to run the end application supplied with the tutorial. Any help would be appreciated.

Thanks,
Jay Easley


System.Reflection.TargetInvocationException was unhandled
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
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.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
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.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.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(Int32 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 Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2.Start() in C:\Program Files\Microsoft Composite UI App Block\CSharp\Source\CompositeUI.WinForms\FormShellApplication.cs:line 31
at Microsoft.Practices.CompositeUI.CabApplication`1.Run() in C:\Program Files\Microsoft Composite UI App Block\CSharp\Source\CompositeUI\CabApplication.cs:line 81
at AdventureWorks.Infrastructure.Shell.ShellApplication.RunInDebugMode() in C:\DotNet\HandsOnLabs\Labs\CS\Developer\04\ex01\end\Source\Infrastructure\Shell\ShellApplication.cs:line 60
at AdventureWorks.Infrastructure.Shell.ShellApplication.Main() in C:\DotNet\HandsOnLabs\Labs\CS\Developer\04\ex01\end\Source\Infrastructure\Shell\ShellApplication.cs:line 51
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()
Jan 30, 2007 at 7:46 PM
This has happened to me frequently. In my case, I was trying to AddInvokers from within SmartParts. This will work but you must be certain the reference to your workitem is good. Mine was not. I have set a property in the Smart Part and the presenter which references the Work Item. I initialize these when I build those components from inside the WorkItem.

Good Luck
Sep 24, 2007 at 6:06 AM
Edited Sep 24, 2007 at 6:06 AM
Might be related to:
http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=15384