Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions CodeMaid.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SteveCadwallader.CodeMaid.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
</configSections>
Expand All @@ -22,12 +22,10 @@
<setting name="Formatting_CommentWrapColumn" serializeAs="String">
<value>100</value>
</setting>
<setting name="Cleaning_InsertBlankLinePaddingBeforePropertiesSingleLine"
serializeAs="String">
<setting name="Cleaning_InsertBlankLinePaddingBeforePropertiesSingleLine" serializeAs="String">
<value>True</value>
</setting>
<setting name="Cleaning_InsertBlankLinePaddingBetweenPropertiesMultiLineAccessors"
serializeAs="String">
<setting name="Cleaning_InsertBlankLinePaddingBetweenPropertiesMultiLineAccessors" serializeAs="String">
<value>True</value>
</setting>
<setting name="Progressing_HideBuildProgressOnBuildStop" serializeAs="String">
Expand All @@ -36,8 +34,7 @@
<setting name="Progressing_ShowBuildProgressOnBuildStart" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_AlphabetizeMembersOfTheSameGroup"
serializeAs="String">
<setting name="Reorganizing_AlphabetizeMembersOfTheSameGroup" serializeAs="String">
<value>True</value>
</setting>
</SteveCadwallader.CodeMaid.Properties.Settings>
Expand Down
6 changes: 3 additions & 3 deletions OletxPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Softwarehelden.Transactions.Oletx
{
/// <summary>
/// The MSDTC patcher applies patches to the distributed transaction implementation in
/// System.Transactions to make promotable transactions work with SQL servers in .NET 6.0. The
/// System.Transactions to make promotable transactions work with SQL servers in .NET Core. The
/// patch would in theory also work for other data providers that support promotable single
/// phase enlistment (PSPE) using the method Transaction.EnlistPromotableSinglePhase() where the
/// database itself or an external service acts as a MSDTC superior transaction manager and can
Expand Down Expand Up @@ -115,7 +115,7 @@ public static bool GetExportCookie(Transaction transaction, byte[] whereabouts,
// MSDTC). System.Transactions calls only the Promote method of the promotable
// single phase notification implemented by the ADO.NET provider and do not call
// the MSDTC API directly which would result in a PlatformNotSupportedException
// on .NET 6.
// on .NET Core.
byte[] propagationToken = transaction.GetPromotedToken();

if (propagationToken != null)
Expand All @@ -129,7 +129,7 @@ public static bool GetExportCookie(Transaction transaction, byte[] whereabouts,

// Note that Azure SQL supports sending the propagation token directly in
// the TDS propagate request to make elastic transactions work natively in
// .NET 6 without querying the MSDTC API.
// .NET Core without querying the MSDTC API.

// Pull the promoted transaction from the source MSDTC to the local MSDTC
// (pull propagation)
Expand Down
2 changes: 1 addition & 1 deletion OletxTransactionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private IDtcProxyShimFactory GetNotificationFactory()
}

/// <summary>
/// .NET 6 applications cannot participate as durable resource manager in the distributed transaction.
/// .NET Core applications cannot participate as durable resource manager in the distributed transaction.
/// </summary>
private class MsdtcResourceManager
{
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Distributed Transactions for MSSQL servers in .NET 6.0
# Distributed Transactions for MSSQL servers in .NET Core Windows

[![NuGet](https://img.shields.io/nuget/v/Softwarehelden.Transactions.Oletx.svg)](https://www.nuget.org/packages/Softwarehelden.Transactions.Oletx)

.NET 6.0 does not support distributed transactions promoted to MSDTC. .NET applications targeting
.NET 6.0 can use this library to enable promotable transactions for Microsoft SQL servers and
volatile resource managers. Below is a list of supported and unsupported .NET data providers.
.NET Core does not support distributed transactions promoted to MSDTC. .NET applications targeting
.NET Core 3.1, .NET 5.0 or .NET 6.0 can use this library to enable promotable transactions for
Microsoft SQL servers and volatile resource managers on the Windows platform. Below is a list of
supported and unsupported .NET data providers.

## How it works

Expand All @@ -17,7 +18,7 @@ When a transaction is being promoted with a custom promoter type, `System.Transa
`Promote()` method of the promotable single phase notification
(`IPromotableSinglePhaseNotification`) to delegate the transaction ownership to an external
transaction manager. Because of the non-MSDTC promoter type, `System.Transactions` does not interact
with the MSDTC API which would result in the `PlatformNotSupportedException` under .NET 6.0.
with the MSDTC API which would result in the `PlatformNotSupportedException` under .NET Core.
Microsoft introduced non-MSDTC promoter types in .NET Framework 4.6.1 to support distributed
database transactions (called elastic transactions) in Azure SQL using a non-MSDTC coordinator.

Expand All @@ -31,7 +32,7 @@ the method `TransactionInterop.GetExportCookie()` to propagate the transaction b
MSDTC services.

This library replaces the default implementation of `TransactionInterop.GetExportCookie()` that
would otherwise throw a `PlatformNotSupportedException` in .NET 6.0 due to MSDTC promotion. The
would otherwise throw a `PlatformNotSupportedException` in .NET Core due to MSDTC promotion. The
patched version of `GetExportCookie()` uses the same MSDTC COM API as the .NET Framework to export
the MSDTC transaction cookie. This is done in three steps:

Expand All @@ -55,15 +56,15 @@ Related .NET issue: https://github.com/dotnet/runtime/issues/715

## How to use

Call `OletxPatcher.Patch()` in the entry point of your .NET 6.0 application:
Call `OletxPatcher.Patch()` in the entry point of your .NET Core application:

```cs
public static class Program
{
public static async Task Main(string[] args)
{
// Patch the OleTx implementation in System.Transactions to support distributed
// transactions for MSSQL servers under .NET 6.0
// transactions for MSSQL servers under .NET Core
OletxPatcher.Patch();

// ..
Expand Down Expand Up @@ -125,8 +126,8 @@ The following .NET data providers are supported:

## Unsupported .NET data providers

- Data provider performs PSPE enlistment but throw an exception when the PSPE enlistment fails (e.g.
`Oracle.ManagedDataAccess.Core` and `MySql.Data`).
- Data provider performs PSPE enlistment but throws an exception when the PSPE enlistment fails
(e.g. `Oracle.ManagedDataAccess.Core` and `MySql.Data`).
- Data provider performs durable enlistment calling `Transaction.EnlistDurable()` or
`Transaction.PromoteAndEnlistDurable()`. Durable enlistment requires coordination between
`System.Transactions` and the local MSDTC which is not implemented in this project.
Expand Down
7 changes: 4 additions & 3 deletions Softwarehelden.Transactions.Oletx.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<Title>Softwarehelden.Transactions.Oletx</Title>
<Description>Library to enable distributed OleTx transactions for Microsoft SQL servers in .NET 6.0</Description>
<Description>Library to enable distributed transactions for Microsoft SQL servers in .NET Core Windows</Description>
<Copyright>Softwarehelden GmbH &amp; Co. KG</Copyright>
<Authors>Softwarehelden GmbH &amp; Co. KG</Authors>
<PackageProjectUrl>https://github.com/softwarehelden-com/Softwarehelden.Transactions.Oletx</PackageProjectUrl>
Expand All @@ -17,6 +17,7 @@

<ItemGroup>
<PackageReference Include="Lib.Harmony" Version="2.2.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0'" />
</ItemGroup>

<ItemGroup>
Expand Down