Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing wrong AggregateRootId gives confusing exception (Non-Static method requires a target) #85

Open
nour-s opened this issue May 11, 2012 · 0 comments

Comments

@nour-s
Copy link

nour-s commented May 11, 2012

When you call a command with wrong AggregateRootId (I mean doesn't exists in the EventSource database), an exception of System.Reflection.TargetException occures.
Here is the problem :
Stack trace
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.<>c__DisplayClass3.b__0(AggregateRoot agg, ICommand cmd) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 21
at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.UoWMappedCommandExecutorCallbacks.ExecuteActionOnExistingInstance(Func2 idCallback, Func2 typeCallback, Action2 action) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 37 at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.<>c__DisplayClass3.<Map>b__2() in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 24 at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootMethodAttributeHandler.Map(MapsToAggregateRootMethodAttribute attribute, ICommand command, IMappedCommandExecutor executor) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootMethodAttributeHandler.cs:line 33 at CallSite.Target(Closure , CallSite , Object , Object , ICommand , IMappedCommandExecutor ) at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.AttributeBasedCommandMapper.Map(ICommand command, IMappedCommandExecutor executor) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\AttributeBasedCommandMapper.cs:line 59 at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.ExecuteInContext(IUnitOfWorkContext context, ICommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 17 at Ncqrs.Commanding.CommandExecution.CommandExecutorBase1.Execute(TCommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\CommandExecution\CommandExecutorBase.cs:line 53
at Ncqrs.NServiceBus.NsbCommandService.b__0(ICommand x)
at Ncqrs.Commanding.ServiceModel.CommandService.Execute(ICommand command) in C:\Projects\ncqrs-ncqrs-ed26668\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 63
at Ncqrs.NServiceBus.NcqrsMessageHandler.Handle(CommandMessage message)

The problem begins in UoWMappedCommandExecutor class in the method (ExecuteActionOnExistingInstance)
in the following line:
var aggRoot = _uow.GetById(type, id, _command.KnownVersion);

aggrRoot is null !! because the id passed value is wrong
so the next line :
action(aggRoot, _command)
will fail.

it tooks me one hour to find out what the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant