Particular / NServiceBus

Build, version, and monitor better microservices with the most powerful service platform for .NET
https://particular.net/nservicebus/
Other
2.09k stars 647 forks source link

InvalidCastException when using transport.DisablePublishing #5642

Closed FrankAnthony11 closed 4 years ago

FrankAnthony11 commented 4 years ago

After updating to nservicebus 7.3 the disable publishing functionality (transportConfiguration.DisablePublishing();) is not working, and the messages are not moved to the .error queue (the critical error is raised).

Version 7.2 works fine.

Transport: MsmqTransport Delayed messages retries are disabled ( endpointConfiguration.Recoverability().Delayed(d => d.NumberOfRetries(0));) Timeout feature is disabled ( endpointConfiguration.DisableFeature();)

 Failed to execute recoverability actions for message `e912f077-71c5-4f41-88e1-745dfd9f3e32\6053014`
System.InvalidCastException: Specified cast is not valid.
Managed Debugging Assistant 'FatalExecutionEngineError' : 'The runtime has encountered a fatal error. The address of the error was at 0x1de241f2, on thread 0x99b4. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
This exception was originally thrown at this call stack:
    ExceptionExtensions.TryReadData<T>(System.Exception, string, out T) in ExceptionExtensions.cs
    Logger.WriteExceptionEvent(string, System.Exception, Serilog.Events.LogEventLevel) in Logger.cs
    NServiceBus.RecoverabilityExecutor.RaiseImmediateRetryNotifications(NServiceBus.Transport.ErrorContext) in RecoverabilityExecutor.cs
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    NServiceBus.Transport.Msmq.ReceiveStrategy.HandleError(System.Messaging.Message, System.Collections.Generic.Dictionary<string, string>, System.Exception, NServiceBus.Transport.TransportTransaction, int) in ReceiveStrategy.cs
kbaley commented 4 years ago

@tonymarkoc I tried to reproduce this here but wasn't able to. The errors still hit the error queue when an exception was thrown. We will need to take a closer look at your endpoint configuration to find the cause. If you aren't able to post your code here, can you open a non-critical support case?

FrankAnthony11 commented 4 years ago

Hi @kbaley , i managed to reproduce it here after adding the packages we use in our solution

I've added:

reproduced.zip

EDIT: need to fix the executable path under debug (nservicebus.host)

kbaley commented 4 years ago

@tonymarkoc Thanks for the reproduction. That helped narrow things down. The short answer is: updating to NServiceBus.Serilog 7.1.0 will fix the problem.

For some background, review this issue.