# System.ValueTuple and .NetFramework 4.7.2

**URL:** <https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [August 18, 2021, 5:55am UTC](https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768 "2021-08-18T05:55:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saket](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Saket](https://discuss.elastic.co/u/Saket)\
**Post date:** [August 18, 2021, 5:55am UTC](https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768/1 "2021-08-18T05:55:32Z")

</div>

**APM Agent language and version** : .NET Framework and 1.11.0

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

The primary reference could not be resolved because it has an indirect dependency on the framework assembly "System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.7.2". To resolve this problem, either remove the reference or retarget your application to a framework version which contains "System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"

Because of this we are not able to build the primary DLL. This is happening in CI/CD server with MSBuild but not with Visual Studio build in local system.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 18, 2021, 7:18am UTC](https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768/2 "2021-08-18T07:18:42Z")

</div>

This looks like a similar issue to

> <https://github.com/dotnet/runtime/issues/27533>
>
> 1. Create a new .NET Framework 4.7.1 console app project.
> 1. Install BenchmarkD…otNet NuGet package.
> 1. Observe that above resulted in \`\<package id="System.ValueTuple" version="4.3.0" targetFramework="net471" /\>\` in \`packages.config\` due to some dependency.
> 1. Paste the following code into Program.cs and excute the app.
> 
> \`\`\`cs
> using BenchmarkDotNet.Attributes;
> using BenchmarkDotNet.Running;
> 
> namespace ConsoleApp3
> {
> internal class Program
> {
> private static void Main(string\[\] args)
> {
> BenchmarkRunner.Run\<Foo\>();
> }
> }
> 
> \[ClrJob\]
> public class Foo
> {
> \[Benchmark\]
> public void Bar()
> {
> 
> }
> }
> }
> \`\`\`
> 
> Expected result: app executes and performs some no-op benchmarks.
> 
> Actual result:
> 
> \`\`\`
> Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. ---\> System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
> --- End of inner exception stack trace ---
> at BenchmarkDotNet.Running.BenchmarkConverter.GetParameterDefinitions(Type type)
> at BenchmarkDotNet.Running.BenchmarkConverter.MethodsToBenchmarksWithFullConfig(Type containingType, MethodInfo\[\] benchmarkMethods, ReadOnlyConfig fullConfig)
> at BenchmarkDotNet.Running.BenchmarkConverter.TypeToBenchmarks(Type type, IConfig config)
> at BenchmarkDotNet.Running.BenchmarkRunner.Run\[T\](IConfig config)
> at ConsoleApp3.Program.Main(String\[\] args) in C:\\Source\\ConsoleApp3\\ConsoleApp3\\Program.cs:line 15
> \`\`\`
> 
> I see the following automatically added to my app.config:
> 
> \`\`\`
> \<dependentAssembly\>
> \<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /\>
> \<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /\>
> \</dependentAssembly\>
> \`\`\`
> 
> I do not see ValueTuple in my bin directory.

Do you have a binding redirect in web.config for `System.ValueTuple`, similar to

```xml
  <dependentAssembly>
    <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
  </dependentAssembly>

```

If so, can you try removing it and recompiling?

---

<div class="post-metadata">

**Author:** ![Saket](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Saket](https://discuss.elastic.co/u/Saket)\
**Post date:** [August 18, 2021, 10:03am UTC](https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768/3 "2021-08-18T10:03:06Z")

</div>

No I do not have this entry in the project that it is added.

I only have this in app.config.

```auto
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Elastic.Apm" publicKeyToken="ae7400d2c189cf22" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.11.0.0" newVersion="1.11.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 8, 2021, 6:03am UTC](https://discuss.elastic.co/t/system-valuetuple-and-netframework-4-7-2/281768/4 "2021-09-08T06:03:40Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
