Sharp 架构任务层错误:未找到命令类型的命令处理程序

发布于 2024-12-11 18:31:26 字数 937 浏览 5 评论 0原文

我目前正在使用 Sharp Architecture 2.0,并且使用效果非常好。但我遇到了在任务层中执行命令的问题。我有以下与我的命令关联的类:

SaveOptionStep1Command,它实现了CommandBaseSaveOptionStep1CommandHandler 实现
ICommandHandler< SaveOptionStep1Command >
SaveOptionStep1CommandResult 实现 CommandResult

当我创建命令时,出现以下错误,并且无法确定问题出在哪里来自。

错误
未找到命令类型的命令处理程序: EasyOptions.Tasks.Commands.SaveOptionStep1Command

描述: 执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

异常详细信息: SharpArch.Domain.Commands.CommandHandlerNotFoundException:未找到命令类型的命令处理程序:EasyOptions.Tasks.Commands.SaveOptionStep1Command

这是我的代码的 Githubu 要点:https://gist.github.com/1314136

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

分分钟 2024-12-18 18:31:26

我发现我错误地创建了存储库。我使用 ClientRepository 类创建存储库,而不是使用接口 IRepositoryWithTypedId 访问它。一旦我更改了我的存储库和处理程序就已正确添加到我的 Windsor 容器中,而没有任何依赖性问题。它现在正在按照我的需要工作。

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.

妥活 2024-12-18 18:31:26

我在使用 SharpArch 2.0.4 时也遇到了同样的问题。
在花了几个小时使用 ComponentsRegistars.cs 进行 Castle 组件注册后,我发现我需要修改 AddTasksTo 方法。
我的观点是,由于命令主要放置在基础设施中,

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

因此它们用 : 替换了旧版本:

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

我认为,最终将选择每个元素。

所以,通过使用第一个版本,问题就解决了。

谢谢

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文