Question

I am currently using Sharp Architecture 2.0 and have been doing pretty well with it. But I am coming on an issue with Performing commands in the Tasks layer. I have the following classes associated with my Command:

SaveOptionStep1Command which implements CommandBase and SaveOptionStep1CommandHandler which implements
ICommandHandler< SaveOptionStep1Command > and
SaveOptionStep1CommandResult which implements CommandResult

When I create the command, I get the below error and cannot determine where the issue is coming from.

ERROR
Command handler not found for command type: EasyOptions.Tasks.Commands.SaveOptionStep1Command

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: SharpArch.Domain.Commands.CommandHandlerNotFoundException: Command handler not found for command type: EasyOptions.Tasks.Commands.SaveOptionStep1Command

Here is a Githubu Gist of my code: https://gist.github.com/1314136

Was it helpful?

Solution

I found out that I was creating the Repositories incorrectly. I was creating my repositories with my ClientRepository class instead of accessing it using the interface IRepositoryWithTypedId. Once I changed that my Repositories and Handlers were correctly added to my Windsor Container without any dependency issues. It is now working as I need it to.

OTHER TIPS

I had the same issue with SharpArch 2.0.4. After spending a couple of hours playing with the ComponentsRegistars.cs for Castle components registration, I figure out the that I need to modify the AddTasksTo method. My viewpoint is that since Commands are mainly placed in Infrastructure, they replace the old version of:

     container.Register(
        AllTypes
            .FromAssemblyNamed("v2.Tasks")
            .Pick().If(t => t.Name.EndsWith("Tasks"))
            .WithService.FirstNonGenericCoreInterface("v2.Domain"));

with this :

 container.Register(
    AllTypes
        .FromAssemblyNamed("v2.Tasks")
        .Pick()
        .WithService.FirstNonGenericCoreInterface("v2.Domain"));

which eventually will pick each and every element, I think.

So, by using the first version, the problem solved.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top