S
SaverioC
Guest
I have build library with Multi targeting (net35,netstandard2.0) and async, but when i reference it in net project tartget > .net 3.5, the compiler throw this:
Error CS0012 The type 'Task<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
this semple projet it reproduce issue:
TPL.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net35'">
<PackageReference Include="AsyncBridge" Version="0.3.1" />
</ItemGroup>
</Project>
FeatureSet.cs
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace TPL
{
public class Response
{
}
public class FeaturesSet
{
public async Task<Response> GoAsync()
{
var timer = new Stopwatch();
timer.Start();
await
#if NET35
TaskEx.Delay(1);
#else
Task.Delay(1);
#endif
timer.Stop();
Console.WriteLine(timer.Elapsed);
return new Response();
}
}
}
Test.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TPL\TPL.csproj" />
</ItemGroup>
</Project>
Program.cs:
using System;
using System.Threading.Tasks;
using TPL;
namespace Test
{
class Program
{
static void Main(string[] args)
{
SyncAdvAsync().GetAwaiter().GetResult();
Console.ReadLine();
}
private static async Task SyncAdvAsync()
{
var f = new FeaturesSet();
await f.GoAsync();
}
}
}
Visual Studio 2017 15.9.12
Continue reading...
Error CS0012 The type 'Task<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
this semple projet it reproduce issue:
TPL.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net35;netstandard2.0</TargetFrameworks>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net35'">
<PackageReference Include="AsyncBridge" Version="0.3.1" />
</ItemGroup>
</Project>
FeatureSet.cs
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace TPL
{
public class Response
{
}
public class FeaturesSet
{
public async Task<Response> GoAsync()
{
var timer = new Stopwatch();
timer.Start();
await
#if NET35
TaskEx.Delay(1);
#else
Task.Delay(1);
#endif
timer.Stop();
Console.WriteLine(timer.Elapsed);
return new Response();
}
}
}
Test.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TPL\TPL.csproj" />
</ItemGroup>
</Project>
Program.cs:
using System;
using System.Threading.Tasks;
using TPL;
namespace Test
{
class Program
{
static void Main(string[] args)
{
SyncAdvAsync().GetAwaiter().GetResult();
Console.ReadLine();
}
private static async Task SyncAdvAsync()
{
var f = new FeaturesSet();
await f.GoAsync();
}
}
}
Visual Studio 2017 15.9.12
Continue reading...