asp.net-mvc - 带有 NServiceBus 的 ASP.NET MVC 2 无法加载请求的类型

标签 asp.net-mvc .net-4.0 nservicebus

我正在尝试将 NServiceBus 与 ASP.NET MVC 2 网站一起使用(使用 VS 2010 和 .NET 4.0 框架)。但是,当我在本地计算机上运行该站点时,出现以下错误:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

以下是我采取的相关步骤:

  • 下载 NServiceBus.2.0.0.1145 二进制文件
  • 在我的 asp.net mvc 应用程序中,我添加了对 NServiceBus.dll 和 NServiceBus.Core.dll 的引用
  • 在 Global.asax.cs 中我添加了:
public static IBus Bus { get; private set; }
protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RegisterRoutes(RouteTable.Routes);

    Bus = NServiceBus.Configure
        .WithWeb()
        .Log4Net()
        .DefaultBuilder()
        .XmlSerializer()
        .MsmqTransport()
            .IsTransactional(false)
            .PurgeOnStartup(false)
        .UnicastBus()
            .ImpersonateSender(false)
        .CreateBus()
        .Start();
}
  • 在 web.config 中,我添加了:
<MsmqTransportConfig 
  InputQueue="MyWebClient" 
  ErrorQueue="error" 
  NumberOfWorkerThreads="1" 
  MaxRetries="5"/>

<UnicastBusConfig>
  <MessageEndpointMappings>
    <add Messages="Messages" Endpoint="MyServerInputQueue"/>
  </MessageEndpointMappings>
</UnicastBusConfig>

该错误表明问题出在 Global.asax.cs 文件中的第一行。有没有可能是NServiceBus在.NET 4.0下运行有问题?

最佳答案

检查 LoaderExceptions 并查看它在提示哪个程序集,然后通过调用 Configure.With(AllAssemblies.Except("problematicAssembly.dll") 而不是 Configure.WithWeb() 来排除它,并将其余流畅的初始化代码保留在一样。

关于asp.net-mvc - 带有 NServiceBus 的 ASP.NET MVC 2 无法加载请求的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2580972/

相关文章:

c# - 如何将图表从 Excel 文件复制到 PowerPoint?

NServiceBus 长时间运行的进程超时

nservicebus - 在 nServiceBus 中订阅来自多个发布者的消息

asp.net-mvc - 使用 REST API 进行身份验证

asp.net-mvc - ASP.NET MVC 适用于复杂的 Web 应用程序吗?

.net-4.0 - 将 VSTO 项目升级到 .net 4 - 我实际需要哪些引用资料?

domain-driven-design - 领域驱动设计概念和与 CQRS 的关系

.net - 转换 Word 文档时 Azure 云上的图像问题。使用 aspose.words 转换为 html

asp.net-mvc - 如何将模型传递给具有其他参数的 Action

c# - LINQ 多重排序依据