4

Had a working ASP.NET Core using a .NET Standard DLL I wrote. I'd like to use TransactionScope in my DLL now, but getting this issue:

.NET Standard and .NET Core 2.0 both recognize System.Transactions, but .NET Framework 4.6.1 is giving an error and won't compile with MSBuild. Visual Studio 2017 offers the following helpful information:

evil tooltip

I cannot seem to find a way to force the project to recognize System.Transactions.dll from my system's Framework/Framework64 folders.

Yes, I can use dotnet build to compile the .NET Core version, but that's not what I want... I want to be able to compile for .NET 4.6.1, too.

sq33G
  • 3,320
  • 1
  • 23
  • 38

1 Answers1

5

You need to add a framework referenced conditioned on the target framework.

Add this to your csproj file:

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
  <Reference Include="System.Transactions" />
</ItemGroup>
Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217