我正在尝试将 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/