c# - System.ArgumentException:通过 Hangfire 任务调用 NServiceBus 时路径不是合法形式
问题描述
当我尝试通过 Hangfire 任务调用 NServiceBus/Rabbit MQ 时出现以下错误我尝试将 .NET Framework 版本从 4.5.2 更新到 4.6.1
不知道我在这里做错了什么?我不断收到此错误但是,当我在本地(通过测试项目)运行它时,消息已成功放置在服务总线上(我能够在服务端点上看到它)
System.AggregateException
One or more errors occurred.
System.AggregateException: One or more errors occurred. ---> System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String fileName)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at NServiceBus.Transport.RabbitMQ.ConnectionConfiguration.Create(String connectionString, String endpointName) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\Configuration\ConnectionConfiguration.cs:line 141
at NServiceBus.Transport.RabbitMQ.RabbitMQTransportInfrastructure..ctor(SettingsHolder settings, String connectionString) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\RabbitMQTransportInfrastructure.cs:line 29
at NServiceBus.RabbitMQTransport.Initialize(SettingsHolder settings, String connectionString) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\RabbitMQTransport.cs:line 18
at NServiceBus.InitializableEndpoint.<Initialize>d__1.MoveNext() in C:\BuildAgent\work\b549d46003942065\src\NServiceBus.Core\InitializableEndpoint.cs:line 49
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NServiceBus.Endpoint.<Start>d__1.MoveNext() in C:\BuildAgent\work\b549d46003942065\src\NServiceBus.Core\Endpoint.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ERM.Messaging.ServiceBus.Client.ServiceBusClient.<StartAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MeterServiceRequest.SyncMeterServiceRequest.<RunAsync>d__1.MoveNext()
--- End of inner exception stack trace ---
at MeterServiceRequest.SyncMeterServiceRequest.<RunAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at ERM.TaskRunner.Server.Impl.TaskWrapper.<RunAsync>d__0.MoveNext() in C:\Code\EMSCore\Apps\TaskRunner\TaskRunner.Server\Impl\TaskWrapper.cs:line 29
---> (Inner Exception #0) System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String fileName)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at NServiceBus.Transport.RabbitMQ.ConnectionConfiguration.Create(String connectionString, String endpointName) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\Configuration\ConnectionConfiguration.cs:line 141
at NServiceBus.Transport.RabbitMQ.RabbitMQTransportInfrastructure..ctor(SettingsHolder settings, String connectionString) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\RabbitMQTransportInfrastructure.cs:line 29
at NServiceBus.RabbitMQTransport.Initialize(SettingsHolder settings, String connectionString) in C:\BuildAgent\work\a9e6741f41af7061\src\NServiceBus.RabbitMQ\RabbitMQTransport.cs:line 18
at NServiceBus.InitializableEndpoint.<Initialize>d__1.MoveNext() in C:\BuildAgent\work\b549d46003942065\src\NServiceBus.Core\InitializableEndpoint.cs:line 49
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NServiceBus.Endpoint.<Start>d__1.MoveNext() in C:\BuildAgent\work\b549d46003942065\src\NServiceBus.Core\Endpoint.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ERM.Messaging.ServiceBus.Client.ServiceBusClient.<StartAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
解决方案
我们通过将 NService Bus 文件(包括 DLL)放在 Hangfire 任务所在的同一台服务器上解决了这个问题,并在 Hangfire 任务解决方案中添加了对 NService Bus 的引用
推荐阅读
- go - 在 Visual Studio 代码中调试 cgo 会产生“多重定义”错误
- python - 绘制 n 次函数的图形
- java - Kafka Consumer - 从每个分区读取 2000 条 LATEST 消息
- c++ - 为什么将一个指针分配给另一个指针会改变 cpp 中的原始指针?
- swift - 从 anyObject 到坐标数组
- office-js - Outlook 加载项可操作消息“Action.InvokeAddInCommand”在 OWA 中没有模式
- amazon-web-services - EMR 集群卡在调整大小上
- ansible - 如何通过索引生成器结果中的列表来选择 1 项?
- mlt - MLT XML:为输入数据指定编解码器
- c# - 简单的 Injector 构造函数参数