System.Reflection.TargetInvocationException

Topics: CAB & Smart Client Software Factory
Nov 12, 2006 at 10:36 AM
originally posted by: NoelEnrique

I was trying to follow the HOL from scratch on my own Smart Client project. I reproduced every step until exercise 2 from lab 3 "Creating a Ship New Order View", checking every step with the solution provided, however I got an error. I will thank anyone who could help me with the following error message:

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.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Microsoft.Practices.ObjectBuilder.CreationStrategy.InitializeObject(IBuilderContext context, Object existing, String id, ICreationPolicy
...
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()
at Microsoft.Practices.CompositeUI.CabApplication`1.Run()
at tecno.Infrastructure.Shell.ShellApplication.RunInDebugMode() in C:\Clientes\ImperSimex\AlquilerSmart\tecnSC3\Source\Infrastructure\Shell\ShellApplication.cs:line 60
at tecno.Infrastructure.Shell.ShellApplication.Main() in C:\Clientes\ImperSimex\AlquilerSmart\tecnSC3\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()
Nov 12, 2006 at 2:39 PM
originally posted by: marianoszklanny

The inner exception will help you understand the root cause of the problem, did you check it out?

It seems that there is an error during the invokation of a constructor, when ObjectBuilder is creating an object.
You might want to post the inner exception details so we can give you more detailed information about the error.

Mariano Szklanny
http://staff.southworks.net/mariano
Nov 14, 2006 at 4:39 AM
originally posted by: NoelEnrique

I had uploaded the project to this url http://ftp.cognosist.com.ve/temp/tecnSC3.zip if anyone wants to see it in detail. I could not understand where is the cause of the exception, I just follow the Hands On Lab instructions.
Thanks
Nov 16, 2006 at 11:14 AM
originally posted by: NoelEnrique

I solved the problem registering the translators in the module.cs:
private IEntityTranslatorService _translator;

InjectionConstructor
public Module(
...
ServiceDependency IEntityTranslatorService translator)
{
...
_translator = translator;
}

public override void Load()
{
...
}

public override void AddServices()
{
base.AddServices();
RegisterTranslators();
}

private void RegisterTranslators()
{
_translator.RegisterEntityTranslator(new AddressTranslator());
_translator.RegisterEntityTranslator(new OrderLineItemTranslator());
_translator.RegisterEntityTranslator(new OrderTranslator());
}