{"record":{"id":"4dc07a15478fbfac","repo":"HangfireIO/Hangfire","slug":"unknown-msmq-transaction-type-transactiontype","errorCode":null,"errorMessage":"Unknown MSMQ transaction type:  + _transactionType","messagePattern":"Unknown MSMQ transaction type:  \\+ _transactionType","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer.Msmq/MsmqJobQueue.cs","lineNumber":103,"sourceCode":"            using (var transaction = new MessageQueueTransaction())\n            {\n                transaction.Begin();\n                messageQueue.Send(message, transaction);\n                transaction.Commit();\n            }\n        }\n\n        private IMsmqTransaction CreateTransaction()\n        {\n            switch (_transactionType)\n            {\n                case MsmqTransactionType.Internal:\n                    return new MsmqInternalTransaction();\n                case MsmqTransactionType.Dtc:\n                    return new MsmqDtcTransaction();\n            }\n\n            throw new InvalidOperationException(\"Unknown MSMQ transaction type: \" + _transactionType);\n        }\n\n        private MessageQueue GetMessageQueue(string queue)\n        {\n            return new MessageQueue(String.Format(CultureInfo.InvariantCulture, _pathPattern, queue));\n        }\n    }\n}","sourceCodeStart":85,"sourceCodeEnd":111,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer.Msmq/MsmqJobQueue.cs#L85-L111","documentation":"InvalidOperationException thrown at the end of MsmqJobQueue.CreateTransaction's switch when _transactionType is neither MsmqTransactionType.Internal nor MsmqTransactionType.Dtc. Because the enum is extensible/serializable, an unexpected (possibly future or deserialized) value reaches the default branch; the message appends the offending value.","triggerScenarios":"Constructing MsmqJobQueue (via UseMsmqQueues configuration) with an MsmqTransactionType value outside the two supported cases; deserializing a config that introduced a new enum member not handled by this version.","commonSituations":"Upgrading Hangfire.SqlServer.Msmq to a version that adds a new transaction type while the calling code passes it to an older library; manually casting an int to MsmqTransactionType; misconfiguration of the MSMQ transaction option in code/config.","solutions":["Set the MSMQ transaction type to one of the supported values: MsmqTransactionType.Internal or MsmqTransactionType.Dtc.","Ensure the Hangfire.SqlServer.Msmq package version matches (or is newer than) the code that supplies the enum value.","Validate the configured value against the known set at startup and fail with a clearer message."],"exampleFix":"// before\n.UseMsmqQueues(path, MsmqTransactionType.None) // unsupported value\n\n// after\n.UseMsmqQueues(path, MsmqTransactionType.Internal)","handlingStrategy":"validation","validationCode":"static readonly HashSet<MsmqTransactionType> Supported =\n    new() { MsmqTransactionType.Internal, MsmqTransactionType.Dtc };\n\nstatic MsmqTransactionType AssertSupported(MsmqTransactionType type)\n{\n    if (!Supported.Contains(type))\n        throw new ArgumentOutOfRangeException(nameof(type), type, \"Unsupported MSMQ transaction type.\");\n    return type;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin Hangfire.SqlServer.Msmq to a version that matches the enum values your code passes.","Default explicitly to MsmqTransactionType.Internal unless DTC is required.","Add a startup config validator for the transaction-type setting."],"tags":["msmq","configuration","enum"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}